Bonjour à tous,
Voici 1 tentative pour réaliser 1 devis en temps réel:
Il doit y avoir 1 erreur dans le code, car quand on fait le total il ne nous donne pas 1 valeur numérique.
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 <!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> </head> <body> <script type="text/javascript"> function radiocoche(Nom) { var r = false; var d = document.forms; for(var i=0; i<d.length; i++) { for(var k=0; k<d[i].length; k++) { if(d[i][k].type=='radio' && d[i][k].name==Nom) { for(var j=0; j<d[i][Nom].length; j++) if(d[i][Nom][j].checked) r = d[i][Nom][j].value; } } } return parseFloat(r); } function boxcochee(Nom) { var r = 0; if (document.getElementById(Nom).checked) r = document.getElementById(Nom).value; return parseFloat(r); } function Calcul() { var res = radiocoche("couleurmaison"); res += radiocoche("nbchambre"); res += boxcochee("jardin"); res += boxcochee("piscine"); res += boxcochee("jacuzzi"); res += parseFloat(document.getElementById("cheminee").value); document.getElementById("total").value=res+" "; } </script> couleur: <p> <input type="radio" name="couleurmaison" value="100" id="blanche" checked /> <label for="blanche"> blanche -> 100 </label> <br /> <input type="radio" name="couleurmaison" value="200" id="rose" /> <label for="rose"> rose -> 200 </label> <br /> <input type="radio" name="couleurmaison" value="300" id="petitpois" /> <label for="petitpois"> à petits pois -> 300 </label> </p> <p>Nb de chambres</p> <p> <input type="radio" name="nbchambres" value="90" id="nbchvaut2" checked /> <label for="nbchvaut2"> 2 -> + 90 </label> <br /> <input type="radio" name="nbchambres" value="110" id="nbchvaut3" /> <label for="nbchvaut3"> 3 -> + 110 </label> <br /> <input type="radio" name="nbchambres" value="150" id="nbchvaut4" /> <label for="nbchvaut4"> 4 et plus -> + 150 </label> </p> <p>Ajout:</p> <p> <input type="checkbox" name="jardin" id="jardin" value="230" /> <label for="jardin">Jardin -> 230 </label> <br /> <input type="checkbox" name="piscine" id="piscine" value="500" /> <label for="jardin"> Piscine -> 500 </label> <br /> <input type="checkbox" name="jacuzzi" id="jacuzzi" value="230" /> <label for="jardin"> Jacuzzi -> 350 </label> </p> <p>Cheminée</p> <p> <select name="cheminee" id="cheminee"> <option value="0">Pas de cheminée</option> <option value="400">Modèle 1 -> 400 </option> <option value="450">Modèle 2 -> 450 </option> <option value="500">Modèle 3 -> 500 </option> <option value="550">Modèle 4 -> 550 </option> <option value="600">Modèle 5 -> 600 </option> <option value="650">Modèle 6 -> 650 </option> <option value="700">Modèle 7 -> 700 </option> </select> </p> <p> <INPUT type="text" maxLength=10 size=10 name=total id="total" value="" readonly> </p> <p> </p> <input type="button" value="Faire le total" onClick="Calcul()"> </body> </html>
J'espère que parmi vous il y aura 1 personne capable de me dire où est l'erreur.
Merci d'avance.
Pascal
Partager