0
votes

I have a form that has Two radio button and a text box that sends information to the database. Text box is initially disabled. When I click Yes it enables the text box and user can input into the text box. When I click no it disables the text box and uploads a pre determined value via hidden input.

Problem: When I click on yes it the text box is still disabled. Not sure what I am doing wrong

HTML code:

<input type="radio" name="TermLease" value="No" onclick="TermLeaseMonths.disabled=true"/>No
<input type="radio" name="TermLease" value="Yes"  onclick="TermLeaseMonths.disabled=false"/>Yes | 
How many months:<input type="hidden" name="TermLeaseMonths"  value="0" />
<input type="text" name="TermLeaseMonths" id="TermLeaseMonths" size="1" disabled="disabled"/>
1
Works fine here in Chrome and FF: jsfiddle.net/j08691/VFJGDj08691
interesting...ok here is the full html form http://jsfiddle.net/wKFAy/1/patgarci
Use this instead: <input type="radio" name="TermLease" value="No" onclick="document.getElementById('TermLeaseMonths').disabled=true"/>No <input type="radio" name="TermLease" value="Yes" onclick="document.getElementById('TermLeaseMonths').disabled=false"/>Yes (disclaimer: I'm against inline JS)j08691

1 Answers

0
votes

Tested in Safari. Works Fine:

<input type="radio" name="TermLease" value="No" onclick="TermLeaseMonths.disabled=true" />No
<input type="radio" name="TermLease" value="Yes" onclick="TermLeaseMonths.disabled=false" />Yes | How many months:
<input type="hidden" name="TermLeaseMonths" value="0" />
<input type="text" name="TermLeaseMonths" id="TermLeaseMonths" size="1" disabled="disabled" />

http://jsfiddle.net/justmake/wKFAy/