4 pièce(s) jointe(s)
limiter les choix de checkbox
hello
me revoici avec mon form
le souci c'est que quand je selectione une boule le compteur de checkbox compte bien mais pas quand je le déselectionne ( il ne fait pas -1 )
si j'inverse les +1 et -1 dans le script le compteur ne fonctionne plus que avec les checkbox normeaux
les boules selectionner ne sont plus envoyer dans la db ni dans la page de resultat (= http://localhost/site/index.php?opti...de&view=valide)
avez vous une idee
voici mes codes
javascript conteur de checkbox
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
| <!--//checkbox loto avec limite 5 script-->
//initial checkCount of zero
var checkCountb=0
//maximum number of allowed checked boxes
var maxChecksb=5
function setChecksb(obj){
//increment/decrement checkCount
if(obj.checked){
checkCountb=checkCountb-1
}else{
checkCountb=checkCountb+1
}
alert(checkCountb)
//if they checked a 6th box, uncheck the box, then decrement checkcount and pop alert
if (checkCountb>maxChecksb){
obj.checked=false
checkCountb=checkCountb-1
alert(+maxChecksb+' boules MAX')
}
} |
javascript changement image des boules
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
| //Checkbox1
var tabimg=new Array()
tabimg[0]=new Image();
tabimg[0].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boule1.png';
tabimg[1]=new Image();
tabimg[1].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boulesb1.png';
function toggleclick(obj){
hiddenname=obj.id.replace(/\D+/,'hidden')
obj.src=(obj.src.indexOf(tabimg[0].src)>-1)?tabimg[1].src:tabimg[0].src
document.getElementsByName(hiddenname)[0].disabled=(obj.src.indexOf(tabimg[0].src)>-1)?true:false;
}
//Checkbox2
var tabimg2=new Array()
tabimg2[0]=new Image();
tabimg2[0].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boule2.png';
tabimg2[1]=new Image();
tabimg2[1].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boulesb2.png';
function toggleclick2(obj){
hiddenname=obj.id.replace(/\D+/,'hidden')
obj.src=(obj.src.indexOf(tabimg2[0].src)>-1)?tabimg2[1].src:tabimg2[0].src
document.getElementsByName(hiddenname)[0].disabled=(obj.src.indexOf(tabimg2[0].src)>-1)?true:false;
}
//Checkbox3
var tabimg3=new Array()
tabimg3[0]=new Image();
tabimg3[0].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boule3.png';
tabimg3[1]=new Image();
tabimg3[1].src='http://localhost/site/components/com_loto/views/loto/tmpl/images/boulesb3.png';
} |
mon formulaire
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| <table><form action="http://localhost/site/index.php?option=com_valide&view=valide" id="loto" name="loto" method="POST">';
echo '<tr>
<td><input="hidden" type="checkbox" name="boule1" id="boule1" value="1" onclick="setChecksb(this)" /><img src="http://localhost/site/components/com_loto/views/loto/tmpl/images/boule1.png" onclick="toggleclick(this)" /></td>
<td><input="hidden" type="checkbox" name="boule2" id="loto" value="2" onclick="setChecksb(this)" /><img src="http://localhost/site/components/com_loto/views/loto/tmpl/images/boule2.png" onclick="toggleclick2(this)" /></td>
<td><input="hidden" type="checkbox" name="boule3" id="boule3" value="3" onclick="setChecksb(this)" /><img src="http://localhost/site/components/com_loto/views/loto/tmpl/images/boule3.png" onclick="toggleclick3(this)" /></td>
</tr></table></form> |
merci d'avance
fred.