Disable radio button on page load
Posted: Mon Feb 06, 2012 5:08 am
<script type="text/javascript">
function disablefield(){
if (document.getElementById('yes_radio').checked == 1){
document.getElementById('forenoon').disabled='disabled';
document.getElementById('forenoon');
document.getElementById('afternoon').disabled='disabled';
document.getElementById('afternoon');
}else{
document.getElementById('forenoon').disabled='';
document.getElementById('forenoon');
document.getElementById('afternoon').disabled='';
document.getElementById('afternoon');
}
}
</script>
<table>
<tr>
<td align="right" valign="top"> </td>
<td colspan="2">
<input type="radio" name="from" id="no_radio" onChange="disablefield();" value="0.5" />
<strong>Half Day
<input type="radio" name="from" id="yes_radio" onChange="disablefield();" value="1" checked="checked" />
Full Day</strong></td>
<td> </td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td colspan="2">
<input type="radio" name="half_day1" id="forenoon" value="Forenoon" />
<strong>Forenoon
<input type="radio" name="half_day1" id="afternoon" value="Afternoon" />
Afternoon</strong></td>
<td> </td>
</tr>
</table>
If want that on page load by default fullday is selected and forenoon and afternoon will be disabled. but if halfday will be selected then forenoon and afternoon will be enabled.
plz help......
function disablefield(){
if (document.getElementById('yes_radio').checked == 1){
document.getElementById('forenoon').disabled='disabled';
document.getElementById('forenoon');
document.getElementById('afternoon').disabled='disabled';
document.getElementById('afternoon');
}else{
document.getElementById('forenoon').disabled='';
document.getElementById('forenoon');
document.getElementById('afternoon').disabled='';
document.getElementById('afternoon');
}
}
</script>
<table>
<tr>
<td align="right" valign="top"> </td>
<td colspan="2">
<input type="radio" name="from" id="no_radio" onChange="disablefield();" value="0.5" />
<strong>Half Day
<input type="radio" name="from" id="yes_radio" onChange="disablefield();" value="1" checked="checked" />
Full Day</strong></td>
<td> </td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td colspan="2">
<input type="radio" name="half_day1" id="forenoon" value="Forenoon" />
<strong>Forenoon
<input type="radio" name="half_day1" id="afternoon" value="Afternoon" />
Afternoon</strong></td>
<td> </td>
</tr>
</table>
If want that on page load by default fullday is selected and forenoon and afternoon will be disabled. but if halfday will be selected then forenoon and afternoon will be enabled.
plz help......