Copy link to clipboard
Copied
I have several groups of radio buttons. If I select the second button of the group (value 2), this selection add “1” to the content of a text field. So, for example, if I select the second value of four radio button groups, the text field shows “4”. How can I do this? Thank you so much
OK. You can use this code as the custom calculation script of the field where you want to display the result, then:
var total = 0;
for (var i=1; i<=8; i++) {
var f = this.getField("ev_"+i);
if (f.valueAsString=="2") total++;
}
event.value = total;
Copy link to clipboard
Copied
So each time you select that button it should increment the value of the text field by 1?
Copy link to clipboard
Copied
No, simply if there are, for example, 8 groups of radiobutton and 3 groups are selected on the second value, the text field show “3”.
Copy link to clipboard
Copied
Ah, so you want to count how many of the second values are selected? What are the names of the groups, and what is the export value of the second fields in them?
Copy link to clipboard
Copied
Right. The radiobuttons groups are “ev_1” ”ev_2” “ev_3” “ev_4”. The export value of the second field is always “2”.
Copy link to clipboard
Copied
OK. You can use this code as the custom calculation script of the field where you want to display the result, then:
var total = 0;
for (var i=1; i<=8; i++) {
var f = this.getField("ev_"+i);
if (f.valueAsString=="2") total++;
}
event.value = total;
Copy link to clipboard
Copied
Right. Thank you so much