https://jumnuoy.blogspot.com/2012/09/select-or-unselect-all-checkbox.html
HTML
<form method="post">
<input type="checkbox" value="on" name="allbox" onclick="checkAll();"/> Check all<br />
<h3>Test</h3>
<input type="checkbox" value="on" name="apples" /> Apples<br/>
<input type="checkbox" value="on" name="oranges" /> Oranges<br/>
<input type="checkbox" value="on" name="bananas" /> Bananas<br/>
</form>
JavaScript
<script language="javascript">Result click here
function checkAll(){
for (var i=0;i<document.forms[0].elements.length;i++)
{
var e=document.forms[0].elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{
e.checked=document.forms[0].allbox.checked;
}
}
}
</script>
HTML
<form method="post">
<input type="checkbox" value="on" name="allbox" onclick="checkAll();"/> Check all<br />
<h3>Test</h3>
<input type="checkbox" value="on" name="apples" /> Apples<br/>
<input type="checkbox" value="on" name="oranges" /> Oranges<br/>
<input type="checkbox" value="on" name="bananas" /> Bananas<br/>
</form>
JavaScript
<script language="javascript">Result click here code form javascript
function checkAll(){
for (var i=0;i<document.forms[0].elements.length;i++)
{
var e=document.forms[0].elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox'))
{
e.checked=document.forms[0].allbox.checked;
}
}
}
</script>
0 comments:
Post a Comment