Expand my Community achievements bar.

hidden/visible form properties with a radio button list

Avatar

Level 1

Hello Everyone,

I am trying to hide/unhide a subform using a radio button list.  I have set the form to dynamic and I am hiding the subforms I don't want to show at runtime.  Then I have a radio button list at the end of the main form that the user can use to show the appropriate subform if they so choose.  I have this working perfectly in another form but for some reason it will not work here.  I am doing this on the click event of the radio button list, there are 3 buttons, one to show subForm1, one to show subForm2, and one to show nothing, the default is value 3 which is nothing. Here is the code I am using

if (rbl.test.rawvalue == 1)

{

form1.sub1.presence="visible";

form1.sub2.presence = "hidden";

}

if (rbl.test.rawvalue == 2)

{

form1.sub1.presence="hidden";

form1.sub2.presence = "visible";

}

if (rbl.test.rawvalue == 3)

{

form1.sub1.presence="hidden;

form1.sub2.presence = "hidden";

}

Any and all help would be greatly appreciated!!!!

7 Replies

Avatar

Level 10

Hi,

If you have taken this script directly from the event, then .rawvalue is incorrect. It should be camel case with a capital 'V' - .rawValue.

Without seeing the form I can't be sure where you have the script, but I would recommend that you have it in the radio button group click event. This way you can have:

if (this.rawValue == 1)

{

     ...

Lastly I would suggest an if/else statement:

if (this.rawValue == 1)

{

     ...

}

else if (this.rawValue == 2)

{

     ...

}

else

{

     ...

}

I hope that helps,

Niall

Avatar

Level 1

Hey Niall,

Thanks for the tip, but that was just a typo on my part, it is rawValue in the Script and it is on the click event.  I tried changing it to an if then else and that didn't seem to affect anything.  i am totally at a loss here and don't know what else to do...   I don't see a way to insert a file in here but I would be glad to send it to you so you can look at it.  Thanks again for the quick reply!

Paul

Avatar

Level 10

Hi Paul,

Looking at the script again, is the missing " in the hidden line below also a type?

if (rbl.test.rawvalue == 3)

{

form1.sub1.presence="hidden; //" missing after hidden

If that is not the issue then a bit of debugging is called for.

First hitting the 'check syntax' button above the script editor will highlight syntax errors:

Parallels Desktop1.png

Then in Preview or Acrobat (not Reader) when viewing the form press Control+J to open the Javascript Console. This will highlight errors, particularly when you click the radio buttons.

Parallels Desktop2.png

Lastly you could include a line of script that will put a line into the Javascript Console, so that you can check that the value of the field is changing:

console.println("The button value is: " + this.rawValue); 

Hopefully that will get it sorted. If you want you can upload your form to Acrobat.com or YouSendIt.com. Remember to publish it and post the URL.

Good luck,

Niall

Avatar

Level 1

Hey Niall,

Thanks again for all of the awesome tips!  I did try all of those suggestions.  I just fat fingered it when I posted it on here which is why there the syntax errors, but in the script it was all correct, the syntax checker did not find any errors.  When I turned on the javascript debugging, it did nothing like there were no scripts???  Not sure of that one.  I did add a line to display the value of the radio button list in a pop up box and it was gettin the correct value but it was not showing the appropriate form;

xfa.host.messageBox('Value of RadioButtonList: ' + rbl_medi.rawValue);

I left all of the testing code in there just commmented it out, of the different suggestions you gave me.  Please check out the below link.

Thanks again!

Paul

https://acrobat.com/#d=aOohks9vWEAgi7E1zsG76Qhttps://acrobat.com/#d=aOohks9vWEAgi7E1zsG76Q

Avatar

Level 10

Hi Paul,

Here is the form back: https://acrobat.com/#d=vQBq5174V3yD7M356-Yc*g

The main issue was that the form was saved as static, whereas making objects hidden and visible increasing the number of pages requires the form to be saved as Dynamic.

Also the if/else works in the click event of the radio button group. I have taken out the script in the click event of the individual radio buttons.

I also moved the hide script from the formReady event to the docReady event (this fires only once).

From a pagination point of view it is better to have each page set to Follow Previous, unless you are forcing it to a different Master Page.

You could also consider hiding the Submit button on page 1 if either of the first two options are selected. This would draw the users onto page 2 where they have to fill in more info and to the Submit button on page 2.

Good luck,

Niall

Avatar

Level 1

Niall,

You are such a lifesaver!  Thank you Thank you Thank you!  I feel so stupid, I could of swore I saved it as static, when I go to file-form properties-defaults, it says that it is a dynamic form, was that not the right place?   Once again thank you so very much.

Paul

Avatar

Level 10

Hi Paul,

The dynamic setting in the File > Form Properties > Defaults only relates if the form is rendered from the server.

If you are using the form directly in Acrobat, it needs to be saved in LC Designer as Dynamic in the save as dialog window:

Parallels Desktop1.png

Select Adobe Dynamic XML Form from the type dropdown.

Good luck,

Niall