Copy link to clipboard
Copied
I have a form with two connected radio buttons i'll like to connect each to specific text fields such that when one radio button is selected, it activates/deactivates specific text fields. The code i'm currently using does not work well during testing. I noticed that when I select one button, it works but when I change my mind and select the other button instead, it deactivates all the fields for both buttons. I used my clear form button to reset the form but the text fields remain deactivated even though no radio button is selected.
Here's the code I used and just interchanged the value and text fields for the substitute button:
if(this.getField('Shelter cost').value == 'renter')
{this.getField('mortgage frequency').readonly = true;
this.getField('monthly mortgage').readonly = true;
this.getField('biweekly mortgage').readonly = true;
this.getField('annual mortgage').readonly = true;
this.getField('annual mortgage 2').readonly = true;
this.getField('Property tax').readonly = true;}
else
{this.getField('mortgage frequency').readonly = false;
this.getField('mortgage frequency').value = "";
this.getField('monthly mortgage').readonly = false;
this.getField('monthly mortgage').value = "";
this.getField('biweekly mortgage').readonly = false;
this.getField('biweekly mortgage').value = "";
this.getField('annual mortgage').readonly = false;
this.getField('annual mortgage').value = "";
this.getField('annual mortgage 2').readonly = false;
this.getField('annual mortgage 2').value = "";
this.getField('Property tax').readonly = false;
this.getField('Property tax').value = "";}
Copy link to clipboard
Copied
Where did you place the code?
Do both script affect the same fields? If so, they will conflict with one another. You will need to create a single script that covers all options.
Copy link to clipboard
Copied
I placed the code in the Actions panel of the radio button with the trigger "Mouse Up" and action "Run a Javascript". I'm new to coding so it's all still kinda confusing for me. I want users to choose between being a renter or a homeowner. If they select the renter radio button, the text fields for mortgage information will be deactivated and they'll only be able to complete the fields for rent information but if they select the button for homeowner, they'll only be able to complete the text fields for mortgage information. What's the best way to go about it?
Copy link to clipboard
Copied
OK, the issue is that the Clear Form command does not trigger this code, then.
You'll need to add a separate script to your Reset Form button to reset the readonly property of the fields to its default state.
Copy link to clipboard
Copied
Ok, can you please give me the script I'll add to the Reset form button?
Copy link to clipboard
Copied
Basically just copy the code in the "else" part of the if-condition in your script.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more