Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jun 12, 2019 Jun 12, 2019

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

TOPICS
Acrobat SDK and JavaScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 12, 2019 Jun 12, 2019

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;

Translate
Community Expert ,
Jun 12, 2019 Jun 12, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 12, 2019 Jun 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”.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2019 Jun 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 12, 2019 Jun 12, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2019 Jun 12, 2019

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 13, 2019 Jun 13, 2019
LATEST

Right. Thank you so much

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines