Expand my Community achievements bar.

SOLVED

Checkbox to hide subform not working

Avatar

Level 4

I have what i think is a fairly simple dilemma. I have a checkbox that will be used to show/hide a subform when checked/unchecked.

However, none of the code I have written seems to work. The checkbox is an object in page1 and not wrapped in any subforms. The subform simply has two text fields in it. the properties of the checkbox have been set so the binding values are 1 for checked, 0 for unchecked. The fields in the subform have presence set to "invisible" as i do not want to show these fields on the form (unless the box is checked).

My code is:

 

form1.Page1.Newspaper::click - (JavaScript, client)

 

if  (this.rawValue == 0) {

xfa.resolveNode("form1.Page1.Newspaper_Subform").presence = "hidden";

}

else {

xfa.resolveNode("form1.Page1.Newspaper_Subform").presence = "visible";

}

  

This code is in the click event under JavaScript. The form is saved as a Adobe dynamic XML form. I am using Adobe XI Pro and LC ES4

I can make this work in the action builder, but i want the subform to go back to hidden when unchecked.

Obviously, a newbie in Java script, so any insights/assistance you may have would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 6

What exactly is the issue?  Is it not showing or not hiding when you change the checkbox?  From your description you have the two text boxes set to invisible but your script is only changing the presence of the subform.  If you show the subform without changing the presence of the textboxes, they will remain invisible.  If you want everything to show/hide together, set the presence of the textboxes to visible and just change the subform presence as you are now.

View solution in original post

4 Replies

Avatar

Level 10

Using your checkbox change_event would be more convenient for what you are trying to do

Avatar

Level 4

Magus069:

Thanks for the suggestion; i changed from click to change. However, the script is still not working.

Still looking for suggestions.

Avatar

Correct answer by
Level 6

What exactly is the issue?  Is it not showing or not hiding when you change the checkbox?  From your description you have the two text boxes set to invisible but your script is only changing the presence of the subform.  If you show the subform without changing the presence of the textboxes, they will remain invisible.  If you want everything to show/hide together, set the presence of the textboxes to visible and just change the subform presence as you are now.

Avatar

Level 4

That was exactly it; the code referenced the subform, not the text objects in the subform. When i changed the presence to your suggestion, the code worked perfectly.

Sometimes you cannot see the forest for the trees.