salut tout le monde
Je me suis lancé dans la programmation d´un site WEB et j´ai fait un petit test sur un sondage du 2nd tour des élections présidentielles 2007.
Le problème, c´est que j´ai voulu approfondir et y ajouter un petit complément, le nombre de personnes ayant votés. J´ai beau retourner le programme, je n´ai toujours pas comprit mon erreur, enfin un peu. Voici le programme:
<html>
<head>
<SCRIPT language="javascript">
<!--
votant = 0
function voter(form1) {
if (form1.choix[0].checked) {alert("Vous venez de voter pour Mr Sarkozy, merci de votre participation")}
if (form1.choix[1].checked) {alert("Vous venez de voter pour Mme Royal, merci de votre participation")}
votant++}
//-->
</SCRIPT>
</head>
<body>
<BODY BGCOLOR="#0000FF">
<font size=15 color="#FFFF00">VOTEZ EST UN ACTE DE CITOYEN<BR>
<BR>
<BR>
<BR>
<BR>
<FORM NAME="form1">
<INPUT TYPE="radio" NAME="choix" VALUE="1">Mr Sarkozy. <BR>
<INPUT TYPE="radio" NAME="choix" VALUE="2">Mme Royal. <BR>
<INPUT TYPE="button" NAME="valide" VALUE="Validation" onClick=" voter(form1)" >
</form>
<SCRIPT language="javascript">
<!--
document.write("Nombre de personnes ayant votés : " + votant)
//-->
</SCRIPT>
</font></font>
</body>
</html>
Je crois qu´il marque 0 car au tout début, j´ai mit votant = 0 et il n´a pas ajouté le +1 quand on fait votant++.
Pouvait vous me dire d´où vient le problème ?, merci d´avance.