Le problème est que j'ai besoin que ma partie name="genre" de mes checkbox soit name="genre[]" car je les traitent ensuite pour les insérer dans une base de données.
Quand name="genre[]" mon script javascript ne marche plus car il n'a pas l'air d'aimer les crochets.
Quelle solution il y a t-il ?
Code : Tout sélectionner
<html>
<head>
<script type="text/javascript">
function allchecked(form) {
var max = form.groupe.length+1;
for (i=1; i<max; i++) {
document.getElementById(i).checked = "checked";
}
}
function nonechecked(form) {
var max = form.groupe.length+1;
for (i=1; i<max; i++) {
document.getElementById(i).checked = "";
}
}
</script>
</head>
<body>
<form>
<select class = "bigroll" id="mabox" type="text" name="status">
<option onclick="nonechecked(this.form)"></option>
<option value="1" onclick="allchecked(this.form)">Administrator</option>
<option value="2" onclick="nonechecked(this.form)">Leader</option>
<option value="3" onclick="nonechecked(this.form)">Member</option>
</select>
<input type="checkbox" id="1" name="groupe" value="9"/>group9<br/>
<input type="checkbox" id="2" name="groupe" value="12"/>group12<br/>
<input type="checkbox" id="3" name="groupe" value="13"/>group13<br/>
<input type="checkbox" id="4" name="groupe" value="3"/>group3<br/>
<input type="checkbox" id="5" name="groupe" value="4"/>group4<br/>
</form>
</body>
</html>