Bonjour,
j'ai créé une page de test toute simple, mais le script ne fonctionne pas et je n'arrive pas à savoir pourquoi :
Le champ montant est censé se mettre à jour lorsque l'on change la quantité, mais ça ne marche pas... Pourquoi ?
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 <!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 type="text/javascript"> function calcul_montant(){ var qte=window.document.getElementById("quantite").value var prix_unit=50 if (isNaN(qte)) {qte=0} var montant=qte*prix_unit window.document.getElementById("montant").value=montant } </script> </head> <body> <form name="commande"> <input name="quantite" type="text" title="quantite" value="" size="10" maxlength="2" onChange="calcul_montant()" /> <input type="text" disabled="disabled" id="prix_unit" maxlength="6" name="prix_unit" size="10" value="" /> <input type="text" disabled="disabled" id="montant" name="montant" maxlength="6" size="10" value="" /> </form> </body> </html>
Partager