Skip to main content
petes22959894
Participant
Jan 9, 2025 12:16 PM UTC
Answered

Checkbox total change colour if greater than & check another checkbox

Hi All,

 

I have a textbox successfully calculating the total of checkboxes checked: 

var total = 0;
for (var i=1; i<=22; i++) {
if (this.getField("OC"+i).value!="Off") total++;
}
event.value = total;

I would like the text to turn red if the total value is greater than 11 and also check another checkbox if the value is greater than 10.

 

Can anybody help?

try67
try67Correct answer
Community Expert
Jan 9, 2025 12:23 PM UTC

Add this to the end of the code:

event.target.textColor = (total>11) ? color.red : color.black;

this.getField("OtherCheckBoxNameGoesHere").checkThisBox(0, total>10);

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Jan 9, 2025 12:23 PM UTC

Add this to the end of the code:

event.target.textColor = (total>11) ? color.red : color.black;

this.getField("OtherCheckBoxNameGoesHere").checkThisBox(0, total>10);

Translate
petes22959894
Participant
Jan 9, 2025 1:33 PM UTC

Thank you very much.

Translate