Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Looping through subforms to hide subforms containing an unchecked Checkbox

Avatar

Level 4

Hi all! I am stuck and would love a little help. I have a form with about 5 levels of subforms. I'm trying run a script with a button click that loops through each subform and hides any subforms that contain an unchecked Checkbox. Here is my hierarchy:

2018-10-22_66.png

So far, I've created a script object called "hide" that has this:

function ToggleRows(reset){

     var Rows = form1.page1.middle.ADDITIONS.EMR.Checkboxes.cb.all;

     var curRow;

     for (var i=0; i<Rows.length; i++){

          curRow = Rows.item(i);

          if (curRow.cb.rawValue == 1){

               curRow.presense = "hidden";}

          else{

               curRow.presense = "visible";}

     }

}

My button is in the "top" subform, and contains this text:

hide.ToggleRows(reset);

Any guidance on this would be greatly appreciated!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi

As well as the presense thing, what is reset.  You pass it in but never use it.  Try just hide.ToggleRows();

View solution in original post

7 Replies

Avatar

Level 7

Hi,

Is this the problem? There is a typo in your code:

presense should be presence

Avatar

Level 4

Oh good catch! Made that correction, but unfortunately no...still not working.

Avatar

Level 7

Just some thoughts....

You could also try specifically naming your subforms rather than using the autonumbering when the same name is used. I found that the number in square brackets in an object name interfered with the reference to an instance which is also a number in square brackets.

Eg: instead of cb[1], have cb1 etc

Using resolveNode has also fixed some issues i have had as well with subforms.

Avatar

Correct answer by
Level 10

Hi

As well as the presense thing, what is reset.  You pass it in but never use it.  Try just hide.ToggleRows();

Avatar

Level 4

Removing "reset" appears to have fixed it! Thank you both for all your help!

Avatar

Level 10

Good news.  Make sure you have "Show console on errors and messages" set in Acrobat, under Edit ... Preferences ... JavaScript as you should have seen a "reset is not defined" message

Avatar

Level 7

Good tip. You can also show the console any time by pressing CTRL+J