I have three check boxes (checkbox1 , 2 and 3) . I want to disable ‘check box 3’ when I click on check box 1 and Enable check box 3 when click check box2. This is working fine, but after adding hidden field for check box 3, the disabling is not working.Please see my code below. Could anyone please help me ?
<html>
<script>
function callFun1()
{
document.getElementById('three').disabled=true;
}
function callFun2()
{
document.getElementById('three').disabled=false;
}
</script>
<head>
<body>
<table border="2" align="center">
<tr><td>CheckBox 1 <input type="checkbox" name="one" id="one" value="true" onClick="callFun1()"></td></tr>
<tr><td>CheckBox 2 <input type="checkbox" name="two" id="two" value="true" onClick="callFun2()"></td></tr>
<tr><td> CheckBox 3 <input type="hidden" name="three" id="three" value=""/>
<input type="checkbox" name="three" id="three" value="true" /> </td> </tr>
</table>
</body>
</head>
</html>
Thanks in advance!
Because you have added a field with the same id and
document.getElementById('three')only returns the first field because id should be unique