Bonjour,
J'ai une petite liste de checkbox dans un formulaire et une checkbox "maitre" qui appelle un script pour toutes les cocher.
Mon code marche très bien sous firefox mais pas sous IE.
Apparement c'est la syntaxte du onClick de ma "box maitre" qui ne passe pas.
Ma box maitre a la valeur Null sous IE.
Aussi bizard, si je supprime mon premier formuleire, ça marche très bien.
Si quelqu'un pourrais m'aider a résoudre ce probleme car je commence a ne plus rien y comprendre.
Merci par avance pour votre aide.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>inventaire</title>
<script type="text/javascript">
//checkbox ou une liste de checkbox.
function selectallbox(cas,choix){alert('ok');
//test si on a plusieur ligne
if(choix.length>0){
if (cas.checked){
for (var i=0; i<choix.length;i++){
choix.checked=true
}
}
else{
for (var i=0; i<choix.length;i++){
choix[i].checked=false
}
}
}
else{
if (cas.checked){
choix.checked=true
}
else{
choix.checked=false
}
}
}
</script>
</head>
<body>
<div id="corps">
<h3>Creation inventaire</h3>
<form action="inventaire-test.html" method="post" name="form1">
<select name="pays" id="pays" >
<option selected>...Choisissez un pays...</option>
<option>Tous</option>
<option>algerie</option>
<option>portugal</option>
<option>italie</option>
<option>espagne</option>
<option>autre</option>
</select> <br><br>
<input type="submit" name="generer_choix" value="Generer choix"
</form>
<br><br>
<div >
<form action="inventaire-test.html" method="post" name="form2">
<br />
<input type="checkbox" name="allChecked" onClick="selectallbox(document.form2.allChecked,document.form2.italie_baby)">
<h3>italie-baby</h3>
<input type="checkbox" id="italie_baby" name="valBox[]" value="502"><input type="text" value="italie-baby-b-xl" ><br>
<input type="checkbox" id="italie_baby" name="valBox[]" value="505"><input type="text" value="italie-baby-b-s" ><br>
<input type="checkbox" id="italie_baby" name="valBox[]" value="506"><input type="text" value="italie-baby-b-xs" ><br>
<br><br>
<input type="submit" name="generer_fichier" value="generer le fichier">
</form>
</div>
<br><br>
</div>
</body>
</html>
[/i]
J'ai une petite liste de checkbox dans un formulaire et une checkbox "maitre" qui appelle un script pour toutes les cocher.
Mon code marche très bien sous firefox mais pas sous IE.
Apparement c'est la syntaxte du onClick de ma "box maitre" qui ne passe pas.
Ma box maitre a la valeur Null sous IE.
Aussi bizard, si je supprime mon premier formuleire, ça marche très bien.
Si quelqu'un pourrais m'aider a résoudre ce probleme car je commence a ne plus rien y comprendre.
Merci par avance pour votre aide.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>inventaire</title>
<script type="text/javascript">
//checkbox ou une liste de checkbox.
function selectallbox(cas,choix){alert('ok');
//test si on a plusieur ligne
if(choix.length>0){
if (cas.checked){
for (var i=0; i<choix.length;i++){
choix.checked=true
}
}
else{
for (var i=0; i<choix.length;i++){
choix[i].checked=false
}
}
}
else{
if (cas.checked){
choix.checked=true
}
else{
choix.checked=false
}
}
}
</script>
</head>
<body>
<div id="corps">
<h3>Creation inventaire</h3>
<form action="inventaire-test.html" method="post" name="form1">
<select name="pays" id="pays" >
<option selected>...Choisissez un pays...</option>
<option>Tous</option>
<option>algerie</option>
<option>portugal</option>
<option>italie</option>
<option>espagne</option>
<option>autre</option>
</select> <br><br>
<input type="submit" name="generer_choix" value="Generer choix"
</form>
<br><br>
<div >
<form action="inventaire-test.html" method="post" name="form2">
<br />
<input type="checkbox" name="allChecked" onClick="selectallbox(document.form2.allChecked,document.form2.italie_baby)">
<h3>italie-baby</h3>
<input type="checkbox" id="italie_baby" name="valBox[]" value="502"><input type="text" value="italie-baby-b-xl" ><br>
<input type="checkbox" id="italie_baby" name="valBox[]" value="505"><input type="text" value="italie-baby-b-s" ><br>
<input type="checkbox" id="italie_baby" name="valBox[]" value="506"><input type="text" value="italie-baby-b-xs" ><br>
<br><br>
<input type="submit" name="generer_fichier" value="generer le fichier">
</form>
</div>
<br><br>
</div>
</body>
</html>
[/i]