Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Show/Hide Subform based on drop-down selection that auto populates radio buttons

Avatar

Level 2

After selecting from the drop-down list it auto populates two different radio buttons. Those radio button fields should show/hide two different subforms.  I get the radio button fields to populate, but can't get the show/hide function to work.   The below is the form without the show/hide function.  https://acrobat.com/#d=zCfWsT0L-QEKMyiA13bH8w  The below form is before I got the auto populate script written but has the show/hide. https://acrobat.com/#d=hJsoYIhezfCuXOr89Twx5Q  Can't seem to get them to work together. Please help.

3 Replies

Avatar

Level 5

Hi,

Looking at the code you have, it has a few mistakes in it that are causing issues

Issue 1

     In the following line of code you are checking if the rawValue is equal to "1", not assigning "1" to be the rawValue;

         OCHR4400.Design1.Request.SIMandatory.SIReq.rawValue == "1";     

     This code should be

           OCHR4400.Design1.Request.SIMandatory.SIReq.rawValue = "1";

Issue 2 ( and this might just be the files that you have uploaded )

     The case statement does not match the dropdown list that you are running it from

     The drop down list has the values ("Books", "Business Cards", "Meeting Room Reservations", etc........)

     But you are testing for valies ("Location A", "Location B", "Location C", etc ...........)

     If you change the code to be something like this then the case statement works

          switch (newVal) {

              case "Books":

                  SIMandatory.SIReq.rawValue = "2";

                break;

              case "Business Cards":

                  OCHR4400.Design1.Request.SIMandatory.SIReq.rawValue = "1";     

                break;

              case "Meeting Room Reservations":

                  OCHR4400.Design1.Request.SIMandatory.SIReq.rawValue = "1";

                break;

          

   default:

         break;}

     Please note you could use the dropdown list to return numbers instead of what is actually selected and this makes coding easier as if you need to change an entry you don't need to change the      code behind it. For example, say the entry "Books" was to be changed to "Text Books" that would then mean the code would not work anymore, more information about this can be found in the      LiveCycle Designer help.

Issue 3

    

     If we assume the fixes above have been done then the rawValue being set is "1", which means that the code you have on the radio buttons

          if (this.rawValue == "1")

           {Design1.SI.presence = "visible";}

          else

          {Design1.SI.presence = "hidden";}

     This means that the item Design1.SI will always be present or not set, which would work unless the user changes their mind as you have no code to change the radio button from Yes to either not      selected OR No, this means that once one of the items from the above list is selected the item will always show, without knowing your full workflow I would recommend that you add a line to the      default of you case statement to change the value of the radio button to "2" and this would mean that your the value of the radio button can be changed.

     So the switch now looks something like this ( I have also removed some unnesserary parts of the path to the rawValue of the radio button)

switch (newVal) {

    case "Books":

        SIMandatory.SIReq.rawValue = "1";

                break;

    case "Business Cards":

        SIMandatory.SIReq.rawValue = "1";

                break;

    case "Meeting Room Reservations":

        SIMandatory.SIReq.rawValue = "1";

                break;

               

default:

    SIMandatory.SIReq.rawValue = "2";

    break;}

Now all of this work still has not actually made your code work as because you are setting the value of the radio button programatically it is not firing the "Change" event and therefore your show hide code is not being run, to do this we need to call the show hide code ourselves and this is achieved by using the following code

SIMandatory.SIReq.execEvent("change");

Please find attached a modified sample of your form which shows the show hide and selction from dropdown list working, as I don;t know how you want it to work I have just guessed to make the example.

https://acrobat.com/#d=*gyMPQHHhnRNk*XUjJZ-dQ

Hope this helps

Malcolm

Avatar

Level 2

I tried using those scripts.  It won't work correctly.  You were using the older form.  When I used those scripts with the newer form, the scripts wouldn't work.  below is the newer form.  Hopefully I can explain a little bit better what I'm trying to do.   When the enduser selects from the drop-down list "Category of Purchase" some things should happen depending on what is selected.  1. The drop-down box "Type of Purchase" is populated with choices based on selected "Category" 2. The IT Mandatory & Special Interest radio button fields are populated YES/NO.  3. Based on the YES/NO radio buttons the subforms for IT Mandtory Signature & Special Interest Signature should be showing/hiding.   I have gotten the first two parts to work but can't get the 3rd.    https://acrobat.com/#d=W1zsK3OBizDKrU*c9-PXQA

Avatar

Level 2

I figured it out. For those who want the script here is the link to the form.

https://acrobat.com/#d=br-ZCbCf9jPZ1HBFP1jaZg