Ich habe ein Javascript gefunden [1], welches mit Hilfe von jQuery [2] alle Checkboxen in einem Formular markiert:
Erstmal müssen die Libraries eingebunden werden:
<script type=”text/javascript” src=”jquery.js”>
</script>
<script type=”text/javascript” src=”jquery.checkboxes.pack.js”>
</script>
Das Formular sieht so aus:
<form action=”" method=”post” id=”test” name=”test”>
<input type=”checkbox” id=”checkall” />Check All
<p />
<?php
for($i = 0; $i < 10; $i++) {
echo ”<input type=’checkbox’ name=’lol[]‘ value=’”.$i.”‘ />
<br />”;
}
?>
<input type=”submit” name=”submit” />
</form>
Der Javascript-Teil der für das checkall verantwortlich ist sieht so aus:
<script>
$(document).ready(function () {
$(‘#checkall’).click(function () {
$(“#test”).toggleCheckboxes();
});
});
</script>
[1] http://www.texotela.co.uk/code/jquery/checkboxes/
[2] http://jquery.com