Display Ads On This Blog

Banner Ads on scriptforphp.blogspot.com
Provides free php script for php developer.
Prix: € 5.00

Friday, June 19, 2009

how to check all checkboxes within a div elemen in javascript

JAVASCRIPT
=======================================
<script type="text/javascript">
function checkByParent(aId, aChecked) {
var collection = document.getElementById(aId).getElementsByTagName('INPUT');
for (var x=0; x if (collection[x].type.toUpperCase()=='CHECKBOX')
collection[x].checked = aChecked;
}
}
</script>
<a href="#" onclick="checkByParent('mydiv', true)">CHECK</a>
<div id="mydiv">
CHECK 1 <input type="checkbox">
CHECK 2 <input type="checkbox">
CHECK 3 <input type="checkbox">
CHECK 4 <input type="checkbox">
CHECK 5 <input type="checkbox">
</div>

3 comments:

  1. it doesn't work

    ReplyDelete
  2. it doesn't work for perticuler condition

    ReplyDelete
  3. teu bisa akh.. ngawadul maneh mah..

    ReplyDelete