0 Replies Latest reply on Sep 6, 2012 3:52 PM by fogharty2

    Show/Hide fields based on choices in drop down menu

    fogharty2

      I need help with a script that I cobbled together from an example script; I'm not good enough at java to edit it for my needs.

      I have a form where I would like different drop down fields would be visible/hidden depending on the choices made from other drop down menus.

      If (for example) they select paper type "white" or "color" then "white" will result in a second menu of paper choices, the "color" selection result in them picking the paper wieght, then from there the color.

       

      My problem stems from the fact that my form is very linited in space, so I would like some of these fields to be essentially on top of each other; visibility dependant on previous choices. I can get to Menu 1 (select paper color) and then Menu 2 if they select white. But there's a problem with setting up a third menu in this series, if they select "color" from Menu 1, then I try to have a drop down for paper weight, all the fields except for Menu 1 are hidden. Playing with the script let me have them all visible, but again, I'm limited on space and can't really spread them out.

       

      I know I'm missing one small command... somewhere.

       

      Here is the script I'm working with:

       

      function control_section_fields() {

       

          if (event.willCommit) return;

       

          // Get the value selected in the combo box

          var section = event.changeEx;

       

         // Hide all of the entry fields

          getField("sec").display = display.hidden;

       

          // Reset all of the entry fields

          resetForm(["sec"]);

       

          // Display the fields for the selected section

          getField("sec." + section).display = display.visible;

       

      }

       

      where the drop down fields are named "sec.a.dd" for example, and the Export value of different values are assigned as "a", "b", etc.

       

      Sorry for the rambling. Any help will be greatly appreciated.