Checkbox liées cochées automatique JavaScript
Oliv
-
Oliv -
Oliv -
Bonjour,
Quelqu'un peut il m'expliquer pourquoi les lignes ci-dessous ne fonctionne pas comme je l'attends: à savoir:
lorsque je coche (ou decoche) la première checkbox, cela NE coche PAS (ou decoche) les deux suivantes!!!
Quelqu'un peut il m'expliquer pourquoi les lignes ci-dessous ne fonctionne pas comme je l'attends: à savoir:
lorsque je coche (ou decoche) la première checkbox, cela NE coche PAS (ou decoche) les deux suivantes!!!
<form name="form4">
<input name="" type="checkbox"
onclick="
this.form.localisation[17].checked=this.checked
this.form.localisation[25].checked=this.checked
" value="" />Tout cocher/Tout décocher ligne 12<br /><br />
<input type="checkbox" name="localisation[17]" value="1">Concorde<br />
<input type="checkbox" name="localisation[25]" value="2">Madeleine<br />
<input type="checkbox" name="localisation[40]" value="3">Chatelet<br />
<input type="checkbox" name="localisation[47]" value="4">Les halles<br />
</form><br />
3 réponses
-
je pense qu'il te faut un ID pour les checkbox et utiliser GetElementById ...
à voir : https://forums.commentcamarche.net/forum/affich-18104160-php-comment-verifier-si-une-case-est-cochee -
Je ne m'explique pas pourquoi la partie fonctionne et pas la seconde: (la seule différence, c'est le name des checkbox qui passe en tableau.
<form name="form4"> <input name="" type="checkbox" onclick=" this.form.localisation1.checked=this.checked this.form.localisation2.checked=this.checked" value="" />Tout cocher/décocher qui fonctionne<br /><br /> <input type="checkbox" name="localisation1" value="1">Concorde<br /> <input type="checkbox" name="localisation2" value="2">chatelet<br /><hr /> <input name="" type="checkbox" onclick=" this.form.localisation[0].checked=this.checked this.form.localisation[1].checked=this.checked" value="" />Tout cocher/décocher qui ne fonctionne pas<br /><br /> <input type="checkbox" name="localisation[0]" value="1">Concorde<br /> <input type="checkbox" name="localisation[1]" value="2">Chatelet<br /> </form> -
Ca y est, j'ai trouvé!
Je ne touche pas à mon tableau qui est deriere le name.
Je travaille avec l'id que je rajoute comme çà:
<input type="checkbox" id="localisation17" name="localisation[17]" value="17" />Argentine
Merci Sapma de m'avoir mis sur la voie!