formulaire deselectionner checkbox lors de selection dun autre checkbox

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : formulaire deselectionner checkbox lors de selection dun autre checkbox

par thehawk » 09 mai 2009, 09:09

Bonjour.
Pourquoi ne pas passer avec les boutons radios ?

Bye Hawk :roll:

par @rthur » 09 mai 2009, 09:09

Bonjour,

J'ai trouvé cela via Google qui devrait correspondre à ce que tu cherche:

Code : Tout sélectionner

<HTML> <HEAD> <SCRIPT> function behaveLikeRadio(thisCheckBox) { if(!thisCheckBox.checked) return; var tableNode = thisCheckBox.parentNode.parentNode.parentNode.parentNode; var checkBoxes = tableNode.getElementsByTagName("INPUT"); for (var i=0; i<checkBoxes.length; i++) { if(checkBoxes[i].name != thisCheckBox.name && checkBoxes[i].type.toLowerCase() == "checkbox" && checkBoxes[i].id == thisCheckBox.id) { checkBoxes[i].checked = false; } } } </SCRIPT> </HEAD> <BODY> One record <TABLE border="1"> <TR> <TD><INPUT type="checkbox" name="Row1_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row1_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row2_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row2_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row3_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row3_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> </TABLE> <BR> Another record <TABLE border="1"> <TR> <TD><INPUT type="checkbox" name="Row1_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row1_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row2_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row2_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row3_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row3_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> </TABLE> </BODY> </HTML>
http://www.experts-exchange.com/Program ... 07624.html

par @rthur » 09 mai 2009, 09:09

Bonjour,

J'ai trouvé cela via Google qui devrait correspondre à ce que tu cherche:

Code : Tout sélectionner

<HTML> <HEAD> <SCRIPT> function behaveLikeRadio(thisCheckBox) { if(!thisCheckBox.checked) return; var tableNode = thisCheckBox.parentNode.parentNode.parentNode.parentNode; var checkBoxes = tableNode.getElementsByTagName("INPUT"); for (var i=0; i<checkBoxes.length; i++) { if(checkBoxes[i].name != thisCheckBox.name && checkBoxes[i].type.toLowerCase() == "checkbox" && checkBoxes[i].id == thisCheckBox.id) { checkBoxes[i].checked = false; } } } </SCRIPT> </HEAD> <BODY> One record <TABLE border="1"> <TR> <TD><INPUT type="checkbox" name="Row1_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row1_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row2_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row2_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row3_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row3_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> </TABLE> <BR> Another record <TABLE border="1"> <TR> <TD><INPUT type="checkbox" name="Row1_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row1_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row2_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row2_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> <TR> <TD><INPUT type="checkbox" name="Row3_Col1" id="Col1" onclick="behaveLikeRadio(this)"></TD> <TD><INPUT type="checkbox" name="Row3_Col2" id="Col2" onclick="behaveLikeRadio(this)"></TD> </TR> </TABLE> </BODY> </HTML>
http://www.experts-exchange.com/Program ... 07624.html

formulaire deselectionner checkbox lors de selection dun aut

par stefane321 » 09 mai 2009, 05:19

Bonjour,

jai une liste de 5 checkbox jaimerais que une fois quil y en a un de sélectionné si jen sélectionne un autre bien que le précédent soit déselectionné

exactement pour pour les radio button

Pouvez-vous m,aider?

Merci