Calculs avec des Checkbox
KOBB
-
KOBB -
KOBB -
Bonjour,
J'ai un beug, avec "Nostalgie" (nos) c'est une valeur négative et il aime pas.
Ensuite, je ne sais pas comment additionner certaines checkbox entre elles.
donc voici les chkbx a additionner entre elles:
acap + apha + afh + anos
acom + abel + avf
agp + sd
asd
dcap + dbdn + dpha + dtour
scom + dbel
dgp + dsd
Merci de votre aide
J'ai un beug, avec "Nostalgie" (nos) c'est une valeur négative et il aime pas.
Ensuite, je ne sais pas comment additionner certaines checkbox entre elles.
donc voici les chkbx a additionner entre elles:
acap + apha + afh + anos
acom + abel + avf
agp + sd
asd
dcap + dbdn + dpha + dtour
scom + dbel
dgp + dsd
<html> function majScore(item,valCb){ var newScore = parseFloat(document.getElementById('score').value); if (item.checked == true){ newScore = newScore+valCb+1; }else{ newScore = newScore-valCb-1; } if(newScore < 0) { newScore = 0; } document.getElementById('score').value=newScore; document.getElementById('aa').value = document.getElementById('score').value; } </script> </head> <body> <form> <input type="hidden" id="score" name="score" size="6" value="0"><p> <input id="aa" name="aa" size="6" value="0" readonly><p> <table> <th width="40px"></th><th width="30px">A</th><th width="30px">D</th><th width="40px"></th><th width="30px">A</th><th width="30px">D</th> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/nos.png)" title="Nostalgie"/></th><th style="background-color:black"><input type='checkbox' id="nos" name="nos" onclick="majScore(this,(-0.1));"></th><th style="background-color:black"></th> <th style="background-image:url(grepo_battlesimulation/bonus/gp.png)" title="Grande Prestresse"/></th><th style="background-color:black"><input type='checkbox' id="gp" name="gp" onclick="majScore(this,0.2);"></th><th style="background-color:black"><input type='checkbox' id="gp" name="gp" onclick="majScore(this,0.2);"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/chance.png)" title="Chance"/></th><th style="background-color:black"></th><th style="background-color:black"><input onkeyup="somab(this.form)" id="chan" name="chan" type="text" style="width: 25px;" /></th> <th style="background-image:url(grepo_battlesimulation/bonus/bel.png)" title="Bellier"/></th><th style="background-color:black"><input type='checkbox' id="bel" name="bel" onclick="majScore(this,0.1);"></th><th style="background-color:black"><input type='checkbox' id="bel" name="bel" onclick="majScore(this,0.1);"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/moral.png)" title="Moral"/></th><th style="background-color:black"></th><th style="background-color:black"><input onkeyup="somab(this.form)" id="moral" name="moral" type="text" style="width: 25px;" /></th> <th style="background-image:url(grepo_battlesimulation/bonus/pha.png)" title="Phalange"/></th><th style="background-color:black"><input type='checkbox' id="pha" name="pha" onclick="majScore(this,0.1);"></th><th style="background-color:black"><input type='checkbox' id="pha" name="pha" onclick="majScore(this,0.1);"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/bdn.png)" title="Bonus de Nuit"/></th><th style="background-color:black"></th><th style="background-color:black"><input type='checkbox' id="bdn" name="bdn" onclick="majScore(this,1);"></th> <th style="background-image:url(grepo_battlesimulation/bonus/tour.png)"/></th><th style="background-color:black"></th><th style="background-color:black"><input type='checkbox' id="tour" name="tour" onclick="majScore(this,0.1);"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/com.png)" title="Commandant"/></th><th style="background-color:black"><input type='checkbox' id="com" name="com" onclick="majScore(this,0.2);"></th><th style="background-color:black"><input type='checkbox' id="com" name="com" onclick="majScore(this,0.2);"></th> <th style="background-image:url(grepo_battlesimulation/bonus/fh.png)" title="Force Héroïque"/></th><th style="background-color:black"><input type='checkbox' id="fh" name="fh" onclick="majScore(this,0.1);"></th><th style="background-color:black"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/cap.png)" title="Capitaine"/></th><th style="background-color:black"><input type='checkbox' id="cap" name="cap" onclick="majScore(this,0.2);"></th><th style="background-color:black"><input type='checkbox' id="cap" name="cap" onclick="majScore(this,0.2);"></th> <th style="background-image:url(grepo_battlesimulation/bonus/vf.png)" title="Vent Favorable"/></th><th style="background-color:black"><input type='checkbox' id="vf" name="vf" onclick="majScore(this,0.1);"></th><th style="background-color:black"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/sd.png)" title="Selection Divine"/></th><th style="background-color:black"><input type='checkbox' id="sd" name="sd" onclick="majScore(this,0.1);"></th><th style="background-color:black"><input type='checkbox' id="sd" name="sd" onclick="majScore(this,0.1);"></th> <th style="background-image:url(grepo_battlesimulation/bonus/cdc.png)" title="Concentration de la chasseresse"></th><th style="background-color:black"><input type='checkbox' id="cdc" name="cdc" onclick="majScore(this,0.15);"></th><th style="background-color:black"></th> </tr> <tr height="45px"> <th style="background-image:url(grepo_battlesimulation/bonus/remp.png)"title="Remparts"></></th><th style="background-color:black" colspan="5"><input onkeyup="somab(this.form)" id="lvl" name="lvl" type="text" style="width: 40px;" value="0" /></th> </tr> </table> </form> </body> </html>
Merci de votre aide
A voir également:
- Calculs avec des Checkbox
- Barbara veut calculer automatiquement son budget dans un tableau. citez un des logiciels lui permettant de faire des calculs sur des tableaux de nombres (tableur). - Forum Musique / Radio / Clip
- Citez un des logiciels lui permettant de faire des calculs sur des tableaux de nombres (tableur). ✓ - Forum LibreOffice / OpenOffice
- Budget plus cic ✓ - Forum finances
- Calculer une moyenne sur excel avec coefficient - Guide
- Excel champ calculé avec condition - Forum Excel
1 réponse
Yop,
Vous n'êtes pas sur la bonne section, ici c'est du Java, vous faites du JavaScript, donc c'est normal que vous ayez peu de réponses.
Ensuite, à quoi servent les + ou - 1 dans le javascript? Si c'est pour faire un cast automatique, c'est un *1 qu'il faut.
Pour ce qui est des scores négatifs, je tenterai d'enlever les majuscules.
Pour bien programmer en JavaScript, il faut installer FireBug (ou un autre du genre) sur votre navigateur, ça vous permettra de voir les erreurs. Ensuite, vous pouvez utiliser console.log(<une var>) pour afficher le contenu d'une variable dans FireBug.
Vous n'êtes pas sur la bonne section, ici c'est du Java, vous faites du JavaScript, donc c'est normal que vous ayez peu de réponses.
Ensuite, à quoi servent les + ou - 1 dans le javascript? Si c'est pour faire un cast automatique, c'est un *1 qu'il faut.
Pour ce qui est des scores négatifs, je tenterai d'enlever les majuscules.
Pour bien programmer en JavaScript, il faut installer FireBug (ou un autre du genre) sur votre navigateur, ça vous permettra de voir les erreurs. Ensuite, vous pouvez utiliser console.log(<une var>) pour afficher le contenu d'une variable dans FireBug.
KOBB
les +/ -1 c'est parce que j'ai essayer de faire en sorte, que la valeur 0 soit 1