This browser does not support basic Web standards, preventing the display of our site's intended design. May we suggest that you upgrade your browser?
Simple check all / uncheck all. This code snippet requires the Prototype library.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Prototype checkbox example</title>
<script src="javascripts/prototype.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript" language="javascript">
function check_all(form){
elements = Form.getInputs(form, 'checkbox');
elements.each( function(checkbox){
//alert(checkbox);
checkbox.checked = true;
});
}
function uncheck_all(form){
elements = Form.getInputs(form, 'checkbox');
elements.each( function(checkbox){
checkbox.checked = false;
});
}
</script>
<form name="mainform" id="my_form">
<table>
<tr>
<td><a href="#" onclick="check_all('my_form'); return false;">Select</a>
<a href="#" onclick="uncheck_all('my_form'); return false;">Deselect</a>
</td>
<td>Name</td>
</tr>
<tr>
<td><input type="checkbox" name="user[delete][1]"></td>
<td>Homer</td>
</tr>
<tr>
<td><input type="checkbox" name="user[delete][2]"></td>
<td>Bart</td>
</tr>
<tr>
<td><input type="checkbox" name="user[delete][3]"></td>
<td>Lisa</td>
</tr>
</form>
</body>
</html>