html radio button if checked - please specify
Posted: Thu Oct 17, 2013 7:36 am
Hi, I have a radio button where I want to display a please specify textbox if the radio button is checked and if the radio button is unchecked again it goes away. Also at the moment I can uncheck the radio button through a reset button I have on the form I just use document.form.reset but is there anyway I can uncheck the radio button by simply clicking on it. Here is what I have so far:
Thanks
Thanks
Code: Select all
<tr>
<td><label>Data Recovery Required?:
</label></td>
<input type="hidden" id="Datarec" name="dataRecYN" value="No"/>
<td>
<input type="radio" id="Datarec" name="dataRecYN" value="Yes"/>
<label id="dataspec" class="hide"><br/>Please Specify: <input type="text" name="txt"/></label></td>
</tr>
<script type="text/javascript">
document.getElementById('Datarec').onchange = function(e) {
var act = document.getElementById('dataspec');
if(this !=checked)
{
act.style.display = 'none';
}
else
{
act.style.display = 'inline';
}
}
</script>