0 Replies Latest reply on May 8, 2017 10:10 AM by Paka222

    Show/hide fields based on drop down menu and conditions

    Paka222 Level 1

      So now that I fixed my validation script for showing and hiding the layers in my acrobat form see (Show/hide layer from drop down menu based on conditions ) I am now having trouble getting the appropriate fields to show.

      I have three drop down menus:

      "1a Performer type"

      "1b Performer type"

      "1c Performer type"

      Each of the above have the following options:

      " " (single space default) (export value = 0)

      "Role" (export value = 1)

      "Understudy Role" (export value = 2)

      I have the following fields:

      "1 Performance Engagement Length"

      "1 Performance Fee"

      "1 Total Performance Fee"

      "Type of Fee"

       

      Here is the code I have created for the "1b Performer type" drop down menu

      var Performer1a = this.getField("1a Performer type").value;

       

      //default and role OR role and role selected - display Performance fields, hide Type of Fee field

      if ( ((event.value ==" ") && (Performer1a==1)) || (( event.value=="Role") && (Performer1a ==1)) )

      {

      this.getField("1 Performance Engagement Length").display = display.visible;

      this.getField("1 Performance Fee").display = display.visible;

      this.getField("1 Total Performance Fee").display = display.visible;

      this.getField("Type of Fee").display = display.hidden;

      }

       

      //default and understudy role OR understudy role and understudy role selected - hide Performance fields, display Type of Fee field

      else if ( ((event.value ==" ") && (Performer1a==2)) || (( event.value=="Understudy Role") && (Performer1a ==2)) )

      {

      this.getField("1 Performance Engagement Length").display = display.hidden;

      this.getField("1 Performance Fee").display = display.hidden;

      this.getField("1 Total Performance Fee").display = display.hidden;

      this.getField("Type of Fee").display = display.visible;

      }

       

      //role and understudy role OR understudy role and role selected - display Performance fields, display Type of Fee field

      else ( ((event.value== "Role") && (Performer1a==2)) || ((event.value== "Understudy Role") && (Performer1a==1)) )

      {

      this.getField("1 Performance Engagement Length").display = display.visible;

      this.getField("1 Performance Fee").display = display.visible;

      this.getField("1 Total Performance Fee").display = display.visible;

      this.getField("Type of Fee").display = display.visible;

      }

      Basically, whenever...

      • "Role" is selected in either the "1a Performer type" field or "1b Performer type" field the first three fields are visible and the forth one is hidden
      • "Understudy Role" is selected in either  the "1a Performer type" field or "1b Performer type" field the first three fields are hidden and the forth one is visible
      • "Role" and "Understudy Role" are selected in the two fields all the fields are visible

       

      Unfortunately, I tried to include this code together with my layer visibility code as a validation script but I kept getting syntax errors, so I ran it as a mouse up execute javascript, but whenever I clicked in the "1b Performer type" field (I didn't even select anything) all the fields appeared. What am I doing wrong?

       

      Any help you can provide would be greatly appreciated.