Enable and disable checkbox

We can disable or enable a checkbox by managing its disabled property. Here is an example on how to make a checkbox enable or disable. We have used getElementByID to know about the checkbox.
document.getElementById('ck1').disabled=true;
To make it enabled we have to use like this
document.getElementById('ck1').disabled=false;
Here is the code
<html>
<head>
<title></title>
<META NAME="DESCRIPTION" CONTENT="">
<META NAME="KEYWORDS" CONTENT="">

<script type="text/javascript">
function chk_control(str) {
if(str=='dsb'){document.getElementById('ck1').disabled=true;}
else {document.getElementById('ck1').disabled=false;}
}
</script>
</head>

<body >

<form name=form1 method=post action=check.php>
<table>

<tr ><td ><input type=checkbox name=ckb id=ck1 value=1></td><td >PHP</td></tr>
<tr ><td ><input type=button value='Disable' onClick="chk_control('dsb')";></td>
<td ><input type=button value='Enable' onClick="chk_control('enb')";></td></tr>
</table></form>
</body>
</html>
Visitors Rating
Your Rating




Google+
More on CheckBox & PHP

Post Comment This is for short comments only. Use the forum for more discussions.




HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2018 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer