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?
this.getField("Answer").value = "Maybe";
Copy link to clipboard
Copied
this.getField("Answer").value = "Maybe";
Copy link to clipboard
Copied
Thank you.
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?
Copy link to clipboard
Copied
Move it to the Validation event and change the first line to:
var mySelection = event.value;
Copy link to clipboard
Copied
Hmm... it's not working for me. Would you mind looking at my PDF?
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.
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.
Copy link to clipboard
Copied
Important to remember: JavaScript is case-sensitive.
Copy link to clipboard
Copied
Right... all my export values are in lower case. Do you see a typo somewhere?
Copy link to clipboard
Copied
The export values of the drop down are not lower case.
Copy link to clipboard
Copied
Sure they are:
Copy link to clipboard
Copied
Right, but the "event.value" property returns the display value, though.
Copy link to clipboard
Copied
Ah.
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.
Copy link to clipboard
Copied
Got it, thank you both!