<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready( function() {
// Select all
$("A[href='#select_all']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', true);
return false;
});
// Select none
$("A[href='#select_none']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").attr('checked', false);
return false;
});
// Invert selection
$("A[href='#invert_selection']").click( function() {
$("#" + $(this).attr('rel') + " INPUT[type='checkbox']").each( function() {
$(this).attr('checked', !$(this).attr('checked'));
});
return false;
});
});
</script>
<fieldset id="group_1">
<form>
<input type="checkbox" name="numbers" value="0" />
<input type="checkbox" name="numbers" value="1" />
<input type="checkbox" name="numbers" value="2" />
<input type="checkbox" name="numbers" value="3" />
<input type="checkbox" name="numbers" value="4" />
<input type="checkbox" name="numbers" value="5" />
<input type="checkbox" name="numbers" value="6" />
<input type="checkbox" name="numbers" value="7" />
<input type="checkbox" name="numbers" value="8" />
<input type="checkbox" name="numbers" value="9" />
</form>
</fieldset>.
<a rel="group_1" href="#select_all">Select All</a>
<a rel="group_1" href="#select_none">Select None</a>
<a rel="group_1" href="#invert_selection">Invert Selection</a>
This is basically jquery check all checkboxes
No comments:
Post a Comment