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

Set the value of a radio button with Javascript

Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Quick syntax question: If I have a radio button group called "Answer" with the options "Yes", "No", and "Maybe", how can I use Javascript to select one of those options?

TOPICS
Acrobat SDK and JavaScript

Views

2.6K

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 , Mar 13, 2019 Mar 13, 2019

this.getField("Answer").value = "Maybe";

Votes

Translate

Translate
Community Expert ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

this.getField("Answer").value = "Maybe";

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Thank you.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

On my test form, I have a dropdown menu (named "Selection") where the user makes their selection, and then on another page, that same selection is displayed in a radio button group (named "Result") with that option checked. The export values in the dropdown and the radio button group are the same. Here's what I did:

On the dropdown menu field, I added a Javascript to be executed on MouseUp:

var mySelection = this.getField("Selection").value;

this.getField("Result").value = mySelection;

I also checked the "Commit selected value immediately" option.

It's not working properly; the selections in the radio group are always one selection behind the selections in the dropdown list, exactly as they would be if I had not selected the "Commit selected value immediately" option. What am I doing wrong?

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Move it to the Validation event and change the first line to:

var mySelection = event.value;

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Hmm... it's not working for me. Would you mind looking at my PDF?

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Sure. You can share it via Dropbox, Google Drive, Adobe Document Cloud, etc., or you can email it to me directly to try6767 at gmail.com.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

I tried sharing it with Dropbox, but I'm not sure if it worked. Here's a link from WeTransfer.

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Important to remember: JavaScript is case-sensitive.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Right... all my export values are in lower case. Do you see a typo somewhere?

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

The export values of the drop down are not lower case.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Sure they are:

export.jpg

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Right, but the "event.value" property returns the display value, though.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

Ah.

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 ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

I would recommend getting rid of the export values and changing the values of the radio-buttons to match those in the drop-down.

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
Mentor ,
Mar 13, 2019 Mar 13, 2019

Copy link to clipboard

Copied

LATEST

Got it, thank you both!

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