Hi Guys,
I have a table and every cell has a tick box.
In the last row I want to calculate how many tick boxes have been checked in the column.
Could anyone advise on the best way to do this?
I'm assuming I need to set a variable to achieve this?
Any help is appreciated!
Solved! Go to Solution.
Views
Replies
Total Likes
For this to work you need a bit of prep work.
All the rows in the table need the same name (except header and footer) - if you've created a static table then they probably don't have the same name. Taking "Row1" as an example you want to name each row "Row1" and you'll see a number in brackets appear after the name (the instance number). All the checkboxes in a column need the same name as well - you'll want each column using a differently named checkbox. This also relies on the checkboxes having the default value for on and off (1 and 0) so we can count them.
The script, using FormCalc, reads through the rows and adds up the value of the named checkbox. Put it on the Calculate event:
$ = sum(Row1[*].CheckBox1)
Views
Replies
Total Likes
For this to work you need a bit of prep work.
All the rows in the table need the same name (except header and footer) - if you've created a static table then they probably don't have the same name. Taking "Row1" as an example you want to name each row "Row1" and you'll see a number in brackets appear after the name (the instance number). All the checkboxes in a column need the same name as well - you'll want each column using a differently named checkbox. This also relies on the checkboxes having the default value for on and off (1 and 0) so we can count them.
The script, using FormCalc, reads through the rows and adds up the value of the named checkbox. Put it on the Calculate event:
$ = sum(Row1[*].CheckBox1)
Views
Replies
Total Likes
Thanks Jono! Spot on! and i learnt something new!
Can this script work in Javascript too?
Views
Replies
Total Likes
You can do it in JavaScript but it takes more code, you need a loop to go through and find the information. FormCalc is easier and calculates faster.
JavaScript (there are several ways of doing this, this is just one):
this.rawValue = null;
var total = 0;
var CB1 = this.resolveNodes("Table1.Row1[*].CheckBox");
for (i = 0; i < CB1.length; i ++) {
total += CB1.item(i).rawValue;
}
total;
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies