Bonjour,
Je me permets de vous soumettre mon code pour avoir votre avis, car rien ne fonctionne.
Le but du jeu, vous l'avez compris, c'est de faire calculer dynamiquement le champ gris en fonction de la saisie des 3 champs en blanc.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Document sans nom</title> <script language="javascript"> function somme() { var t = parseFloat(document.forms["form"].elements["val1"].value) + parseFloat(document.forms["form"].elements["val2"].value) + parseFloat(document.forms["form"].elements["val3"].value); parseFloat(document.forms["form"].elements["valt"].value) = t.toFixed(2); } </script> <style type="text/css"> #valt { color: #FFF; background-color: #666; } </style> </head> <body> <form name="form" action="Ajout" method="post"> <table width="100" border="0" cellspacing="0" cellpadding="0"> <tr> <td><input name="valt" type="text" id="valt" value="0" /></td> <td><input type="text" name="val1" value="0" onBlur="somme()"/></td> <td><input type="text" name="val2" value="0" onBlur="somme()"/></td> <td><input type="text" name="val2" value="0" onBlur="somme()"/></td> </tr> </table> </form> </body> </html>
Je suis novice en javascript, merci de votre aide
Bien Cordialement, stéphane
Partager