Expand my Community achievements bar.

SOLVED

Select all / Check all - Checkboxes in a table with multiple rows

Avatar

Former Community Member

Adobe Livecycle Designer ES2

HI,

I have several checkboxes that I need to make a check all option for. I have it working but it's inneficient and time consuming given the number of times this has to be done. I need like 5 of these per page, 20+ rows per page, 10 pages per document, and about 7 documents total :S

On click event of the checkbox has the following code:

if (this.rawValue == '1')

{

     form1.facility.Table6.Row2.Subform7.pharmacy1.rawValue = '1';

     form1.facility.Table6.Row3.Subform7.pharmacy2.rawValue = '1';

     <....>

}

else

{

     form1.facility.Table6.Row2.Subform7.pharmacy1.rawValue = '0';

     form1.facility.Table6.Row3.Subform7.pharmacy2.rawValue = '0';

     <....>

}
The name "subform7" does not change, Table6 does but I can always rename the rest of them, form1 doesn't change, facility does change (and not just facility1, facility2...etc, can be anything).
Using this heirarchy is there a better way check these? Here's what I was playing around with but it didn't work:
for(var myRows in form1.facility.Table6)
{
     // Renamed all of them to be "pharmacy"
     myRows.Subform7.pharmacy.rawValue = '1';
}  
If someone can shed some light that would be great.

1 Accepted Solution

Avatar

Correct answer by
Level 7

You must be using formCalc and the rows must be reNamed so that LCD shows them as Row[0], Row[1], Row[3] ... etc. in the Hiearchy tab

I am a little confused by the subform residing within a table row--although it is possible to do this. So, I assume that this is correct. One good way to make sure you have the correct SOM for the checkbox is to CTRL click one of these checkboxes while your cursor is in the Scrpt Editor.

Good luck!

View solution in original post

6 Replies

Avatar

Level 7

Hi,

The way I handle this is to use formCalc and name the checkboxes the same (I've used generic names here).

subform[*].table[*].row[*].checkbox = "1"

This will set all the checkboxes. Play around with it and see if something like this will work.

Or, you could construct a nested loop in javaScript or formCalc and that would decrease the number of lines needed.

Good luck!

Stephen

Avatar

Former Community Member

Hi,

I am getting the following error:

     Error: accessor 'form1.facility.Table5.Row[*].Subform7.facility1' is unknown.

Here's the code I wrote:

     form1.facility.Table5.Row[*].Subform7.facility1 = "1"

Thanks.

Avatar

Correct answer by
Level 7

You must be using formCalc and the rows must be reNamed so that LCD shows them as Row[0], Row[1], Row[3] ... etc. in the Hiearchy tab

I am a little confused by the subform residing within a table row--although it is possible to do this. So, I assume that this is correct. One good way to make sure you have the correct SOM for the checkbox is to CTRL click one of these checkboxes while your cursor is in the Scrpt Editor.

Good luck!

Avatar

Former Community Member

Alrighty, after a re-naming nightmare I now have something that's more or less copy + pastable. Thanks for the help.

if (form1.facility.Table5.checks.subform[3].CheckAll == "1") then

     form1.facility.Table5.Row[*].Subform7.facility = "4"

     form1.facility.Table5.checks.subform[*].CheckAll = "0"

     form1.facility.Table5.checks.subform[3].CheckAll = "1"

else

     form1.facility.Table5.Row[*].Subform7.facility = "0"

     form1.facility.Table5.checks.subform[*].CheckAll[*] = "0"

endif

Avatar

Level 7

Hint: You can rename multiple like objects (multiple rows or multiple checkboxes, etc) by highlighting them in the Hiearchy Pallet and changing the name in the Binding tab of the Object Pallet--change them all at once.

Avatar

Former Community Member

Thanks,

The subform is in place to allow easier positioning of all the checkboxes (5 per row).

What I do is join the cells into one, paste the subform, then break the cells apart again and reapply the border.

It lets me paste a subform into one cell while maintaining the checkbox positions and it doesn't stretch the table. I have a border around the other 4 cells which surround the checkboxes making a nice little box around the checkboxes.