integration de script "tout cocher" php / javascript
Bonjour je voudrais utiliser un script permettant de tout cocher ou tout decocher mes checkbox, le script je l'ai et il fonctionne sur un modele simple, mais je n'arrive cependant pas a l'adapter avec mon code php si quelqu'un pouvait m'aider..
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
<script type="text/javascript">
<!--
// choix = '0' pour tout décocher
// choix = '1' pour tout cocher
// choix = '2' pour inverser la sélection
function GereChkbox(conteneur, choix) {
var blnEtat=null;
var Chckbox = document.getElementById(conteneur).firstChild;
while (Chckbox!=null) {
if (Chckbox.nodeName=="INPUT")
if (Chckbox.getAttribute("type")=="checkbox") {
blnEtat = (choix=='0') ? false : (choix=='1') ? true : (document.getElementById(Chckbox.getAttribute("id")).checked) ? false : true;
document.getElementById(Chckbox.getAttribute("id")).checked=blnEtat;
}
Chckbox = Chckbox.nextSibling;
}
}
//-->
</script>
</head>
<body>
<?php
require('connectionBD.php');
//-----------------------------------------------------------------------------------------------
function select_entreprises($code)
{
connection();
$result = mysql_query("select * from entreprises where id_entreprise = $code");
return $result;
};
//-----------------------------------------------------------------------------------------------
echo"<form action=traitement_doublons2_E.php method=POST>";
if (isset($_POST['bouton']))
{
for ($i = 0, $c = count($_POST['bouton']); $i < $c; $i++)
{
$res = select_entreprises($_POST['bouton'][$i]);
$r = mysql_fetch_array($res);
echo "
<tr>
<td><input type='button' value='Tout selectioner' onClick='GereChkbox('div_chck','1');'></td>
<td><input type='button' value='Deselectioner' onClick='GereChkbox('div_chck','0');'></td>
<div id='div_chck'>
<td><input type='radio' name='bouton' value = '".$r[0]."' id='bouton' /></td>
<td><input type='hidden' name='id_entreprise$i' value = '".$r[0]."' id='id_entreprise$i' /><label for='id_entreprise$i'>$r[0]</label></td>
<td><input type = 'checkbox' name='checkbox1' id='checkbox1' value = '".$r[1]."'></input><label for='code_entreprise'>$r[1]</label></td>
<td><input type = 'checkbox' name='checkbox2' id='checkbox2' value = '".$r[2]."'><label for='nom'>$r[2]</label></td>
<td><input type = 'checkbox' name='checkbox3' id='checkbox3' value = '".$r[3]."'><label for='adr_rue'>$r[3]</label></td>
<td><input type = 'checkbox' name='checkbox4' id='checkbox4' value = '".$r[4]."'><label for='adr_compl'>$r[4]</label></td>
<td><input type = 'checkbox' name='checkbox5' id='checkbox5' value = '".$r[5]."'><label for='adr_cp'>$r[5]</label></td>
<td><input type = 'checkbox' name='checkbox6' id='checkbox6' value = '".$r[6]."'><label for='adr_ville'>$r[6]</label></td>
<td><input type = 'checkbox' name='checkbox7' id='checkbox7' value = '".$r[7]."'><label for='adr_pays'>$r[7]</label></td>
<td><input type = 'checkbox' name='checkbox8' id='checkbox8' value = '".$r[8]."'><label for='tel'>$r[8]</label></td>
<td><input type = 'checkbox' name='checkbox9' id='checkbox9' value = '".$r[9]."'><label for='fax'>$r[8]</label></td>
</tr>";
};
};
echo' <br /><br />
</table>
<input type=submit name="mofidier" value="modifier" />
</div></form>';
?>
</body>
</html> |
quelqu'un a une idée ??
Merci d'avance ;)