Skip navigation
mkaylah21
Currently Being Moderated

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

Aug 4, 2012 2:13 PM

Tags: #javascript #forms #livecycle #drop-down #radio_button

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.

 
Replies
  • Currently Being Moderated
    Aug 6, 2012 6:55 AM   in reply to mkaylah21

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points