Bonjour,
Je suis photographe et je souhaite mettre en place un formulaire de "pré-commande" de photos sur mon blog.
L'utilisateur saisirait ses coordonnées puis :
- Nom de la séance photos (liste déroulante)
- Référence photo (texte)
- Format photo (liste déroulante)
-Impression (liste déroulante)
-Quantité (texte)
En fonction du format, de l'impression et de la quantité, le prix affiché doit changer.
Je vois ça sous forme de tableau avec un bouton "ajouter" et un bouton "supprimer"
A la fin un total s'affiche et en cliquant sur "valider", j'aimerai recevoir sa commande par mail.
Voici ce que j'ai "rassemblé" après diverses recherches :
Le but étant de pouvoir mixer le tout pour répondre à ma demande.
J'ai un peut de mal avec les tableaux et l'incrémentation d'où ma demande d'aide.
Merci
Olivier
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 <td style="width: 196px;">Total Hors Taxe : <div id="s1"><input name="prixht" id="prixht" type="text" readonly="readonly" /></div> </td> <input onclick="test()" type="button" value="test" /> <title> Tableau de commande </title> <script language="javascript"> function test(){ var prixht = document.getElementById('prixht'); var vs1 = 270; var vs2 = 10; prixht.value = vs1 + vs2 ; } function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[1].cells[i].innerHTML; //alert(newcell.childNodes); switch(newcell.childNodes[0].type) { case "text": newcell.childNodes[0].value = ""; break; case "checkbox": newcell.childNodes[0].checked = false; break; case "select-one": newcell.childNodes[0].selectedIndex = 0; break; } } } function deleteRow(tableID) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { if(rowCount <= 2) { addRow(tableID); // alert("Cannot delete all the rows."); // break; } table.deleteRow(i); rowCount--; i--; } } }catch(e) { alert(e); } } </script> <script language="javascript"> function Format(selection) { if (selection.value == "10*15") { var quantite = document.getElementById('quantite'); prix_format= 1; var prix = document.getElementById('prix'); prix.value = quantite * prix_format; } else if (selection.value == "11*15") { var prix = document.getElementById('prix'); var quantite = document.getElementById('quantite'); prix_format= 2; var prix = document.getElementById('prix'); prix.value = quantite * prix_format; } else if (selection.value == "20*30") { var quantite = document.getElementById('quantite'); prix_format= 3; var prix = document.getElementById('prix'); prix.value = quantite * prix_format; } else { // do something } } function calcul(){ } </script> </fieldset> </form> </head> <body> <table border="1" id="TableID" style="width: 350pxpx;"> <tr> <th bgcolor="grey" td="" width="15"></th><th bgcolor="grey" td="" width="90">Séance</th><th bgcolor="grey" td="" width="90">Référence</th><th bgcolor="grey" td="" width="75">Format</th><th bgcolor="grey" td="" width="45">Impression</th><th bgcolor="grey" td="" width="45">Quantité</th><th bgcolor="grey" td="" width="45">Prix</th></tr> <tr> <td><input name="chk" size="15" type="checkbox" /></td> <td> <select name="Séance" style="width: 90;"> <option selected="" value="Sélectionnez votre séance">Sélectionnez votre séance</option> <option selected="" value="Séance 1">Séance 1</option> <option value="Séance 2">Séance 2Séance 2</option> </select> <td><input name="Ref" size="25" type="text" /></td> <td> <select onchange="Format(this)" style="width: 90;"> <option value="10*15">10*15</option> <option value="11*15">11*15</option> <option value="20*30">20*30</option> </select> </td> <td> <select name="Impression" style="width: 10;"> <option value="Mat">Mat</option> <option value="Brillant">Brillant</option> <option value="Satiné">Satiné</option> </select> </td> <td><input name="Quantite" id="quantite" size="2" type="text" /></td> <td><input name="prix" id="prix" size="3" type="text" readonly="readonly" /></td> </tr> </table> <input onclick="addRow('TableID')" type="button" value="Ajouter" /> <input onclick="deleteRow('TableID')" type="button" value="Supprimer" /> </body></html>
Partager