These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Does this code work?

JCASE
Registered: May 12 2010
Posts: 29

Does this JavaScript code work for a check box event? I see a lot of examples of if/else code for one action, but I needed a check box to change multiple objects. It does work, but I wasn't sure if it was the correct way to do it.

if (this.rawValue == "1") {
text1.presence = "visible";
text2.presence = "visible";
text3.presence = "visible";
} else {
text1.presence = "invisible";
text2.presence = "invisible";
text2.presence = "invisible";
}

My Product Information:
LiveCycle Designer, Windows
Niall
Expert
Registered: Apr 26 2006
Posts: 62
As you say it does work. You could put it in the click or exit event. Because the checkbox has only two states on/off, 1/0 then the if/else statement works well with one test (as you have it). If you were scripting a dropdown with lots of choices then a switch statement would work better.

If you had lots of objects to show/hide you could wrap these in a single subform and then just set the presence of the subforms instead of the individual objects.

Niall

Hope this helps,

Niall
Assure Dynamics

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
If you have multiple check boxes within the exclusionary group, you have to decide what you want to have happen for each check box, and then use the code that processes all of the options for the check box group. Since you will be using the same code in multiple fields, you might consider using a function to perform this task, so when you need to edit the code, there is only one script that needs to be changed and not a script for each check box. Since you need to use JavaScript for functions, you might consider using a 'switch' statement instead of nested 'if' statements.

George Kaiser