Skip to main content
Known Participant
January 31, 2025
Question

Determine field value based on Radio buttons - custom calculation not working

  • January 31, 2025
  • 1 reply
  • 634 views

I'm trying to do something that should be simple, but it's not working.

 

FIRST

 

I think I have the right code, but not sure:

 

var frequency = this.getField("1_Year").value;

if (frequency == "Off") {
Amount.value = "100";
}
else if (frequency == "On") {
Amount.value = "200";
}

 

Would this output "100" into field "Amount" for off and "200" for on?

 

SEDCONDLY:

 

when I type this into a custom calculation field and hit ok, acrobat closes the window as if it's accepted it, but when I look at the box, it has gone back to "value is not calculated", which is obviously not what I want.

 

Any help?

1 reply

Known Participant
January 31, 2025

Well, I think I figured it out, but I can't edit or delete this post so. oh well?

Thom Parker
Community Expert
Community Expert
January 31, 2025

Here's an article that covers the basics of scripting radio buttons:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

Basically, the default "On" value for a radio button is "Yes". But this is also the export value, which you can change to be whatever you want. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Known Participant
January 31, 2025

Thanks Thom, I do understand that, but my arger issue is part two. I'm writing what I think is correct code, but it's just dissappearing once I type it in. Any help there?