Skip to main content
Inspiring
June 12, 2019
Answered

To select a radio button add a number in a text field

  • June 12, 2019
  • 1 reply
  • 1105 views

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

This topic has been closed for replies.
Correct answer try67

Right. The radiobuttons groups are “ev_1” ”ev_2” “ev_3” “ev_4”. The export value of the second field is always “2”.


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;

1 reply

try67
Community Expert
Community Expert
June 12, 2019

So each time you select that button it should increment the value of the text field by 1?

Inspiring
June 12, 2019

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”.

try67
Community Expert
Community Expert
June 12, 2019

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?