These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Set Radio Button based on Value of another field

csgorup1
Registered: Jan 14 2010
Posts: 3

I have been given this form to update. I have a field that calculates the total cost based of information entered into several other fields. I have a set of 4 radio buttons with a value of 0 to 3. If the total amount is less then 1000 I want to turn on the radio button with the value of 0, less then 5000 1, less then 10000 2 otherwise 3.

Can anyone help me with the code and where to put it.

My Product Information:
Acrobat Pro 8.0, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The value of radio buttons or check boxes has the property of being able to be read or written. So you can use an 'if' or 'switch' statement to determine what value to the set the radio button to. The value of radio buttons or check boxes when no value is set is 'Off'.

this.getField('RadioButtonFieldname').value = 'Off'; // clear buttonsif(this.getField('TotalAmountFieldName').value < 1000) {this.getField('RadioButtonFieldname).value = 0;}if(this.getField('TotalAmountFieldName').value < 5000) {this.getField('RadioButtonFieldname).value = 1;}if(this.getField('TotalAmountFieldName').value < 10000) {this.getField('RadioButtonFieldname).value = 2;}if(this.getField('TotalAmountFieldName').value => 10000) {this.getField('RadioButtonFieldname).value = 3;}

You will have to adjust the code for your field names.

George Kaiser

csgorup1
Registered: Jan 14 2010
Posts: 3
Thank you - you got me in the ballpark and I was able to figure out the rest. Don't know if it's a version thing or a setting in my acrobat but I had to change your single quotes to double quotes. You were missing a quote at the end of RadioButtonFieldName. And I had to make it ELSE because everything was less then 10000. I added code to make all the boxes off if the amount was 0, but I had to put it at .01 not 0.

For individuals in the future that stubble on this here is my code

this.getField("RADIOBUTTONFIELDNAME").value = "Off";
if(this.getField("TOTALAMOUNTFIELDNAME").value < .01) {
this.getField("RADIOBUTTONFIELDNAME").value = "Off";
} else {
if(this.getField("TOTALAMOUNTFIELDNAME").value < 1000) {
this.getField("RADIOBUTTONFIELDNAME").value = 0;
} else {
if(this.getField("TOTALAMOUNTFIELDNAME").value < 5000) {
this.getField("RADIOBUTTONFIELDNAME").value = 1;
} else {
if(this.getField("TOTALAMOUNTFIELDNAME").value < 10000) {
this.getField("RADIOBUTTONFIELDNAME").value = 2;
} else
{
this.getField("RADIOBUTTONFIELDNAME").value = 3;
}}}}