There will be two types of checkboxes one is the general checkbox and the second is the checkbox array. There will be a scenario that we need to read the value from the checkbox or the checkbox array.
Writing a javascript for the general checkbox is more easy when compared to the checkbox array. We need to write the javascript for checkbox array For example : We have a music options available and we need to provide option to enable the disable the checkbox array.
The below code explains how to enable and disable the checkbox array.
<Html>
<head>
//Music skills
function musicskills(value)
{
if(value==1)
{
chkvaluer=document.form.elements['chkmusic[]'];
for (r=0;r<chkvaluer.length;r++)
{
chkvaluer[r].disabled = true;
}
document.form.txtmusic.disabled = true;
}else{
chkvaluer=document.form.elements['chkmusic[]'];
for (r=0;r<chkvaluer.length;r++)
{
chkvaluer[r].disabled = false;
}
document.form.txtmusic.disabled = false;
}
}
</head>
<body>
<form name="form" method="post" action="testfile.php">
<input type="radio" value="yes" onClick="musicskills(0);">Yes
<input type="radio" value="no" onClick="musicskills(1);">No
<input type="checkbox" name="chkmusic[]" value="Punjabi">Punjabi
<input type="checkbox" name="chkmusic[]" value="classical">Classical
<input type="checkbox" name="chkmusic[]" value="devotional">Devotional
<input type="checkbox" name="chkmusic[]" value="westren">Westren
</body>
</html>
"Hi, I Saw Your Link in Bing.com I Love Your Blogs Kindly See my Link Here a New Alternative Money Making Network alternative to adbrite here
ReplyDelete"