Copy link to clipboard
Copied
I have four radio buttons on an Acrobat form and I would like to run some if statements based on the response to which radio button is clicked. I assume that you use Radio Button Choice in some way to determine the response, but I can't find any code that shows how to check the response.
I've changed each of the radio buttons shown above to have different Radio Button Choice fields. Can someone provide an idea of what to do to set a variable in javascript based on which button they click?
Thanks,
Russ
Copy link to clipboard
Copied
To check the value e.g.:
this.getField ("group Name").value
Copy link to clipboard
Copied
To get that variable, I currently have the following line:
//Check application type
var app = +getField("ApplicationType").value;
If I run the java console and set event.value = app, the output is [object app] when I am looking for the output to be Radio Button Choice.
Copy link to clipboard
Copied
app is a reserved keyword. Use a other name.
Copy link to clipboard
Copied
You weren't very clear what you need but if i got it right you want to use different variables depending which radio button is clicked. You can try soemthing like this:
var a = this.getField("Text1").value;
var b = this.getField("Text2").value;
var rb = this.getField("Group1");
if(rb.value == "Choice1")
event.value = a;
else if(rb.value == "Choice2")
event.value = b;
Copy link to clipboard
Copied
I need to be able to have a radio button input that is used in if statements for another field value. I've changed all the Radio Button Choices to different text and I assume that if I set a variable like the following:
var appType = +getField("ApplicationType").value;
Then I set
event.value = appType;
that I will get the output to be the Radio Button Choice currently selected. I'm just not getting it to output that way. The way that radio button is set will have an impact on a field below, but I'm not sure how to use it in the Boolean logic.
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
Try this:
var appType = this.getField("ApplicationType").value;
if(appType != "Off")
event.value = appType;
else event.value = "";