Codice PHP:
<!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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
*{
margin:0px;
padding:0px
}
input,textarea{
width:150px
}
textarea{
height:150px
}
</style>
<script language="JavaScript" type="text/JavaScript">
function checkMe (pItem, pForm) {
var _form= document.getElementById(pForm);
if (pItem.checked) {
for (var i=0;i< _form.elements.length;i++) {
if (_form.elements[i].name.substring(0,4) == "chk_") {
_form.elements[i].checked = true;
}
}
} else {
// Deseleziona tutto
for (var i=0;i< _form.elements.length;i++) {
if (_form.elements[i].name.substring(0,4) == "chk_") {
_form.elements[i].checked = false;
}
}
}
}
</script>
</head>
<body>
<form action="indexForum.php" method="post" name="frm" id="mio">
<input name="check_from" type="hidden" value="<?php echo time();?>" />
<input name="chk_title[]" onclick="checkMe(this,'mio');" type="checkbox" value="1" />
<input name="chk_title[]" onclick="checkMe(this,'mio');" type="checkbox" value="2" />
<input name="chk_title[]" onclick="checkMe(this,'mio');" type="checkbox" value="3" />
<input name="chk_title[]" onclick="checkMe(this,'mio');" type="checkbox" value="4" />
<input name="save_item" onclick="" type="submit" value="Save" />
</form>
</body>
</html>