Bonjour,
J ai un formulaire qui contient 3 listes deroulantes.
Je veux quand je clique, il fait un controle avant qu il me dirige vers une autre page, si tout marche, sinon je reste dans la meme page.
Voila mon formulaire :Et voila mon script
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 <form name="form1" method="post" action="" onSubmit="controle();"> <table border="0" width="79%" align="center"> <tr> <th width="45%"><div align="left">Société:</div></th> <td width="55%"> <? $req2 = "select * from societe ORDER BY `soc_org` ASC "; $query2 = mysql_query($req2); ?> <SELECT onChange="location.href='form_commander.php?pays=<? echo $pays?>&id_soc='+this.options[selectedIndex].value" style="width:250" name="ste" id="ste"> <option value='0'>Société</option> <? while($row2 = mysql_fetch_assoc($query2)) { ?> <option value="<? echo $row2['code_soc']?>"<? if ($row5['id'] == $row2['id']) {?> selected="selected"<? }?>><? echo $row2['soc_org']?></option> <? } ?> </SELECT></td> </tr> <tr> <th width="45%"><div align="left">Contact:</div></th> <td width="55%"> <? if ($_GET["id_soc"] != "") { $id_soc = $_GET["id_soc"]; $req = "select code_soc from societe where id = $id_soc"; $res = mysql_query($req); $row = mysql_fetch_assoc($res); $req3 = "select * from contact where code_soc='".$row['code_soc']."'"; $query3 = mysql_query($req3); $res3 = mysql_num_rows($query3); if($res3!=0) { ?> <select name='id' style='width:250px' id='id' onChange="location.href='form_commander2.php?pays=<? echo $_GET["pays"]?>&id_soc=<? echo $_GET["id_soc"] ?><? if(isset($_GET["nom"])){?>&nom=<? echo $_GET["nom"]?>&pages=<? echo $_GET["pages"]?>&prenom=<? echo $_GET["prenom"]?>&mail=<? echo $_GET["mail"]; }?><? if(isset($_GET["ville"])){?>&ville=<? echo $_GET["ville"]?>&soc_org=<? echo $soc_org?>&ser_lab=<? echo $ser_lab?>&cp=<? echo $cp?>&tel=<? echo $tel?>&page=<? echo $_GET["page"]?>&fax=<? echo $fax;}?><? if(isset($_GET["cmd"])){?>&cmd=<? echo $_GET["cmd"]; }?><? if(isset($_GET["p"])){?>&p=<? echo $_GET["p"]; }?><? if(isset($_GET["h"])) {?>&h=<? echo $_GET["h"]; }?><? if(isset($_GET["page"]))?>&page=<? echo $_GET["page"]?>&id='+this.options[selectedIndex].value"> <option value='0'>contact</option> <? while($row3 = mysql_fetch_assoc($query3)) { if ($_GET["id"] == $row3['id']) { ?> <OPTION value="<? echo $row3['id']?>" selected='selected'><? echo $row3['nom']." ".$row3['prenom']?></OPTION> <? } else { ?> <OPTION value="<? echo $row3['id']?>"><? echo $row3['nom']." ".$row3['prenom']?></OPTION> <? } } ?> </select> <? } else { ?> <span class="Style1">IL N'Y A PAS DE CONTACT POUR CETTE SOCIETE VEUILLEZ VERIFIER LA BASE DE DONNEES </span> <? } } ?> </td> </tr> <tr> <th width="45%"><div align="left">Mode de la commande :</div></th> <td width="55%"> <? $req4 = "select * from type_cmd"; $query4 = mysql_query($req4); ?> <select name="mode" style="width:250" id="mode" <? if(isset($_GET["p"])) { if($p==11) { ?>onChange="location.href='form_commander2.php?id=<? echo $id?>&pays=<? echo $pays?>&p=<? echo $p?><? if($p==11){ ?>&cmd=<? echo $_GET["cmd"]; }?>&id_soc=<? echo $id_soc?>&mode='+this.options[selectedIndex].value"<? } elseif($p==12) { ?>onChange="location.href='form_commander2.php?id=<? echo $id?>&pays=<? echo $pays?>&p=<? echo $p?><? if($p==12){ ?>&cmd=<? echo $_GET["cmd"]; }?>&id_soc=<? echo $id_soc?>&page=<? echo $_GET["page"]?>&mode='+this.options[selectedIndex].value"<? } elseif($p==14) { ?>onChange="location.href='form_commander2.php?id=<? echo $id?>&page=<? echo $_GET["page"]?><? if($p==14){ ?>&cmd=<? echo $_GET["cmd"]; }?>&pays=<? echo $pays?>&p=<? echo $p?>&id_soc=<? echo $id_soc?>&mode='+this.options[selectedIndex].value"<? } elseif($p==15) { ?>onChange="location.href='form_commander2.php?id=<? echo $id?>&page=<? echo $_GET["page"]?>&pays=<? echo $pays?>&p=<? echo $p?><? if($p==15){ ?>&cmd=<? echo $_GET["cmd"]; }?>&id_soc=<? echo $id_soc?>&mode='+this.options[selectedIndex].value"<? } } elseif(isset($_GET["h"])) { if($h==3) { ?>onChange="location.href='form_commander2.php?cmd=<? echo $_GET["cmd"]?>&page=<? echo $_GET["page"]?>&id=<? echo $id?>&h=<? echo $h?>&pays=<? echo $pays?>&ville=<? echo $ville?>&soc_org=<? echo $soc_org?>&ser_lab=<? echo $ser_lab?>&cp=<? echo $cp?>&tel=<? echo $tel?>&fax=<? echo $fax?>&id_soc=<? echo $id_soc?>&mode='+this.options[selectedIndex].value"<? } elseif($h==1) { ?>onChange="location.href='form_commander2.php?pays=<? echo $_GET['pays']?>&h=<? echo $h?>&nom=<? echo $_GET['nom']?>&prenom=<? echo $_GET['prenom']?>&mail=<? echo $_GET['mail']?>&pages=<? echo $_GET['pages']?>&id=<? echo $_GET['id']?>&id_soc=<? echo $_GET['id_soc']?>&cmd=<? echo $_GET['cmd']?>&page=<? echo $_GET['page']?>&mode='+this.options[selectedIndex].value"<? } } ?> > <option value="0">Mode</option> <? while($row4 = mysql_fetch_assoc($query4)) { ?> <option value="<? echo $row4['id_type_cmd']?>" <? if($row4['id_type_cmd'] == @$_GET['mode']) { ?> selected="selected" <? } ?> ><? echo $row4['type_cmd']?></option> <? } ?> </select> </td> </tr> <tr> <td colspan="2"><div align="center"> <? if(@$_GET['mode']!=0) { ?> <br><input type="submit" name="submit" value="valider"> <? } ?> </div> </td> </tr> </table> </form>Mais il me donne une erreur et ça marche pas. Quelqu'un a une idée?
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 <script language="javascript"> function controle() { a= window.confirm('Etes-vous sûr de vouloir RENOUVELER cette COMMANDE?'); if(a) { alert('test'); } else { document.location.reload(); return (false); } } </script>
Merci d'avance pour vos reponses
Partager