I have here a code that whenever I checked a checkbox the button will enable but if I unchecked it the button will be disabled. My problem is that, when I add another checkbox the disable and enable of button doesn't work. The output should be whenever I checked one or more checkbox the button will enable but if there's no checkbox that has been checked the button should be disabled. Anyone knows how I can do that?
Here's my code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function Disab(id)
{
if(document.form1.cbox.checked)
{
document.form1.Button1.disabled=false
}
else {
document.form1.Button1.disabled=true
}
}
</SCRIPT>
</HEAD>
<BODY TEXT="000000" BGCOLOR="FFFFFF">
<form name="form1">
<div align="center">
<input name="cbox" type="checkbox" id="cbox2" value="checkbox" onClick=Disab(this.id);>
Click here to Enable/Disable Button<br /><br />
<input type=button onClick="alert('Button pressed!')" value="Button" name="Button1" disabled>
</div>
</form>
</BODY>
</HTML>
Aucun commentaire:
Enregistrer un commentaire