Javascript for radio button to activate or deactivate text fields
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 = "";}
