Automatically select correct check box based on choices made in previous section?

Avatar

Avatar
Validate 1
Level 1
mattpn2719
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
mattpn2719
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
mattpn2719
Level 1

30-06-2015

Using LiveCycle to create a form containing a table. This table has 3 columns with 15 check boxes in each column.

Below these 15 rows are 3 more check boxes that have calculated values. In each row of the table only one of the check boxes can be checked at a time.

Based on the majority of choices in a certain column, the corresponding calculated check box should be checked. (If the most choices are made in column 1, then the 1st calculated check box must be checked, etc...)

The trouble I'm having is writing the JavaScript code that selects the correct calculated check box. Currently I'm just trying to figure it out with only the top 3 rows and I can replicate the pattern after.

Ex. of table: (Bold represents calculated)

CheckBox20CheckBox35CheckBox50
CheckBox21CheckBox36CheckBox51
CheckBox22CheckBox37CheckBox52
[   ] CheckBox66[   ] CheckBox67

[   ] CheckBox68

Here's the code I've come up with so far but it doesn't work right whatsoever, although when I used it just for 2 columns it did work. (just added the part about the third column with the "or" statements)

(In the calculate script of check box 66)


//larger values than other columns
if ((Row1.CheckBox20.rawValue == "") + (Row2.CheckBox21.rawValue == "") + (Row3.CheckBox22.rawValue == "") > (Row1.CheckBox35.rawValue == "") + (Row2.CheckBox36.rawValue == "") + (Row3.CheckBox37.rawValue == "") || (Row1.CheckBox50.rawValue == "") + (Row2.CheckBox51.rawValue == "") + (Row3.CheckBox52.rawValue == ""))
{this.rawValue = "0";}



//smaller values than other columns
if ((Row1.CheckBox35.rawValue == "") + (Row2.CheckBox36.rawValue == "") + (Row3.CheckBox37.rawValue == "") || (Row1.CheckBox50.rawValue == "") + (Row2.CheckBox51.rawValue == "") + (Row3.CheckBox52.rawValue == "") > (Row1.CheckBox20.rawValue == "") + (Row2.CheckBox21.rawValue == "") + (Row3.CheckBox22.rawValue == ""))
{this.rawValue = "1";}


I'm new to JavaScript so all advice is appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

30-06-2015

Looking at the conditions, it looks like you're trying to say "if column 1 has more than column 2 or column 3, then do something." JavaScript can't read conditions like that. It's reading "if (column 1 has more than column 2) OR (column 3)," and it doesn't know what to do with that column 3 number unless it's 0 or 1.

Here's an example using only two rows and three columns. The rawValues are 0 and 1 for each checkbox. I've set it so that if column 1 has more checkboxes, then Col1 gets checked. Similarly, the col2 or 3 boxes get checked if their columns are the highest populated. I didn't include the possibility of having multiple checkboxes marked if there are two columns that have the same number of boxes checked. (You could do that by just changing > to >= in the conditions.)

783865_pastedImage_0.png

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
mattpn2719
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
mattpn2719
Level 1

Likes

0 likes

Total Posts

7 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
mattpn2719
Level 1

02-07-2015

Thanks jasotastic81, this is exactly what I was looking for.