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

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

Community Beginner ,
Jun 12, 2019 Jun 12, 2019

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

TOPICS
Acrobat SDK and JavaScript

Views

896

Translate

Translate

Report

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;

Votes

Translate

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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?

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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;

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Right. Thank you so much

Votes

Translate

Translate

Report

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