bonjour,
je fais une formulaire avec plusieurs liste deroulante mais la derniere liste impose sont choix au deux autres quelqu'un peut me dire comment faire pour que chaque liste soit independante.
voici mon code
et voila le ram.php (ecran.php et ecran 2 sontsur la meme base)
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 <!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=iso-8859-1" /> <title>Document sans nom</title> <? require_once'ajax.php'; connect(); ?> <script type="text/javascript" language="javascript"> function calcule() { ram_prix = document.getElementById('ram').value; ecran_prix = document.getElementById('ecran').value; clavier_prix = document.getElementById('clavier').value; total = parseInt(ram_prix,10)+ parseInt(ecran_prix,10)+ parseInt(clavier_prix,10); document.getElementById('le_total').innerHTML = (isNaN(total))?"0":total; document.getElementById('ram').innerHTML = (isNaN(total))?"0":ram_prix; } </script> </head> <body> <form id="form" method="post" action="test2.php"> <table border="0"> <tr> <td><strong>Type</strong></td> <td><strong>Produit</strong></td> <td><strong>Prix</strong></td> <td><strong>Description</strong></td> </tr> <tr> <td>Ram </td> <td><? include 'ram.php'?></td> <!--<td><input type="text" onkeyup="ram.innerHTML=(1*this.value); calcule();" /></td>--> </tr> <tr> <td>Ecran</td> <td><? include 'ecran.php'?></td> <!-- <td><input type="text" onkeyup="ecran.value=(2*this.value); calcule();" /></td> <td><input type="text" id="ecran" value="0" /></td>--> </tr> <tr> <td>Ecran2</td> <td><? include 'ecran.php'?></td> <!--<td><input type="text" onkeyup="clavier.value=(4*this.value); calcule();" /></td> <td><input type="text" id="clavier" value="0" /></td>--> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><strong>total</strong></td> <td></td> <td></td> <td id="le_total">0</td> </tr> <tr> <td> </td> <td></td> <td></td> <td> </td> </tr> <tr> <td colspan="2">Nom : </td> <td><input type="text" id="contact_nom" /></td> <td> </td> </tr> <tr> <td colspan="2">E-mail : </td> <td><input type="text" id="contact_mail" /></td> <td> </td> </tr> <tr> <td> </td> <td></td> <td></td> <td> </td> </tr> <tr> <td> </td> <td></td> <td></td> <td><input type="submit" name="Submit" value="Envoyer" /></td> </tr> </table> </form> </body> </html>
ps le code est fortement inspirer de celui de corinne
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 <?php //////////////////////////////////////////////////////////////// //declaration des variables //////////////////////////////////////////////////////////////// //decalration des differentes ram $var='2 giga'; $var1='3 giga'; $var2='4 giga'; // on crée la requête SQL $table = 'conf_ram'; $sql = "SELECT * FROM $table WHERE nom='$var'"; // on envoie la requête $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); // on fait une boucle qui va faire un tour pour chaque enregistrement while($data = mysql_fetch_assoc($req)) { // on affiche les informations de l'enregistrement en cours echo '<form method="post" action="test2.php">'; echo '<select name="dd" size="1" onChange="ram.value=('.def($var,$table).'); calcule();"> <option value="0"' ; if(!isset($_POST['dd']) || $_POST['dd']==0 ){echo 'selected';} echo '> '.$var. '</option>; <option value="1"'; if(@$_POST['dd']==1){echo 'selected'; } echo '>' .$var1. '</option>; <option value="2"' ; if(@$_POST['dd']==2){echo 'selected'; } echo '>' .$var2. '</option>;'; } echo '<td><input type="text" onchange="ram.value=('; require_once 'ajax.php'; if(!isset($_POST['dd']) || $_POST['dd'] == 0){ echo '<td><input type="text" id="ram" value="'; prix($var,$table); echo '" /></td>'; echo '<td>'; desc($var,$table); } if(@$_POST['dd'] == 1){ echo '<td><input type="text" id="ram" value="'; prix($var1,$table); echo '" /></td>'; echo '<td>'; desc($var1,$table); } if(@$_POST['dd'] == 2){ echo '<td><input type="text" id="ram" value="'; prix($var2,$table); echo '" /></td>'; echo '<td>'; desc($var2,$table); } echo '</td>'; ?>
Partager