<html> <head> <script language="JavaScript"> <!-- function operation(chiffre1, chiffre2, signe) { switch (signe) { case 0 : return parseInt(chiffre1) + parseInt(chiffre2); break; case 1 : return chiffre1 - chiffre2; break; case 2 : return chiffre1 * chiffre2; break; case 3 : if (chiffre2 != 0) return chiffre1 / chiffre2; else return "division par 0"; } } //--> </script> </head> <body> <form method="POST" name="op"> <table border="0" cellpadding="3" cellspacing="0" width="100%"> <tr> <td width="55%" valign="top">Indiquez 2 chiffres :<br> <input type="text" name="chiffre1" size="10"> <input type="text" name="chiffre2" size="10"> <p>Résultat :<br> <input type="text" name="resultat" size="20"> </td> <td width="45%" valign="top">Opération :<br> <select size="4" onChange="document.op.resultat.value = operation(document.op.chiffre1.value, document.op.chiffre2.value, this.selectedIndex)"> <option>addition</option> <option>soustraction</option> <option>multiplication</option> <option>division</option> </select> </td> </tr> </table> </form> </html>
Pas mal, déjà vu mais un petit problème : il faudrait qu'on puisse mettre plus de 2 chiffres... 7/10
Se souvenir du profil
Mot de passe oublié ? / Activation de compteCréer un compte