Bonjour a tous !
Voila j'ai écrit cette page html/javascript et lorsque je l'execute, une erreure se produit si j'appuie deux vois sur ok...
voyez vous meme :
<html>
<head>
<title>pgcd et ppcm de deux nombres</title>
<script language="JavaScript">
function pgcd(){
a=window.document.calcul.a.value;
b=window.document.calcul.b.value;
if (a<b)
{r=a;
a=b;
b=r;}
r=a%b;
while(r!=0)
{a=b;
b=r;
r=a%b;}
pgcd=b;
ppcm();
}
function affiche(){
pgcd();
window.document.calcul.pgcd_correc.value=pgcd;
window.document.calcul.ppcm_correc.value=ppcm;
}
function ppcm(){
a=window.document.calcul.a.value;
b=window.document.calcul.b.value;
ppcm=(a*b)/pgcd;
}
function verif(){
pgcd();
pgcd_util=window.document.calcul.pgcd_util.value;
ppcm_util=window.document.calcul.ppcm_util.value;
if(pgcd_util==pgcd)
if(ppcm_util=ppcm)
alert("Bravo !");
else
alert("Le pgcd est faux !");
else
alert("le pgcd est faux");
}
</script>
</head>
<body>
<form name="calcul">
A=<input type="text" size="7" name=a>
B=<input type="text" size="7" name=b><br><br>
<B>Votre solution :</B><br><br>
PGCD<input type="text" size="10" name="pgcd_util">
PPCM<input type="text" size="10" name="ppcm_util">
<input type="button" value="ok" onClick="JavaScript:verif();"><br><br>
<B>La correction</B><br><br>
PGCD<input type="text" size="10" name="pgcd_correc" disabled>
PPCM<input type="text" size="10" name="ppcm_correc" disabled>
<input type="button" value="ok" onClick="JavaScript:affiche();">
</form>
</body>
</html>
en fait on clique sur ok et on verifie ce que l'utilisateur a rentré
mais apres on ne peut pas revérifier ses solutions si on les a changées ou voir la correction.
aidez moi svp....!!!!!!!! :D