[AJAX] Liste et champs texte liées
Bonjour,
je ne suis pas du tout familier avec le langage ajax ( et donc js aussi) mais voilà on m'a fait comprendre que pour mon problème, ajax est très recommendé. Voilà je souhaite réaliser un configurateur de pc en ligne, pour cela l'utilsateur doit preciser par le biais de 6 listes déroulantes le choix de ses composants (dd, ram, proc, carte mere....), ces 6 listes sont alimentés par 6 tables mysql, chaque table ayant deux champ ref et prix, je recupere bien sur la champ ref pour mes listes, voilà mon probleme, j'aimerais que tout de suite après avoir choisi un composant, le prix de ce composant là soit affiché à coté dans un champ texte, ce champs est bien sur alimenté par le table correspondante. Pouvez vous s'il vous plait m'indiquez comment faire ? Voici le script de mon configurateur.
Code:
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
| <!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 titre</title>
</head>
<body>
<form name="form1" method="get" action="inser.php">
<table width="227" height="194" border="1">
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">Carte Mere</font></th>
<td><label>
<select name="cartem" id="cartem">
<?php
$SQL = "SELECT nom FROM cartesm";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input name="pcartem" type="text" id="pcartesm" value="" readonly="readonly">
</label></td>
</tr>
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">Processeur</font></th>
<td><label>
<select name="proc" id="proc">
<?php
$SQL = "SELECT nom FROM proc";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input type="text" name="pcproc" id="pcproc">
</label></td>
</tr>
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">RAM</font></th>
<td><label>
<select name="ram" id="ram">
<?php
$SQL = "SELECT nom FROM ram";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input type="text" name="pcram" id="pcram">
</label></td>
</tr>
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">Disque Dur</font></th>
<td><label>
<select name="DD" id="DD">
<?php
$SQL = "SELECT nom FROM dd";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input type="text" name="pcdd" id="pcdd">
</label></td>
</tr>
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">Carte Video</font></th>
<td><label>
<select name="cartev" id="cartev">
<?php
$SQL = "SELECT nom FROM cartesv";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input type="text" name="pccartev" id="pccartev">
</label></td>
</tr>
<tr>
<th scope="row"><font face="Verdana" style="font-size: 8pt; text-align: left;" color="#808080">Lecteur</font></th>
<td><label>
<select name="lec" id="lec">
<?php
$SQL = "SELECT nom FROM lecteur";
$res = mysql_query($SQL);
while($val=mysql_fetch_array($res)) {
echo "<option>".$val["nom"]."</option>\n";
}
?>
</select>
</label></td>
<td><label>
<input type="text" name="pclec" id="pclec">
</label></td>
</tr>
<tr>
<th colspan="2" scope="row">Prix Total</th>
<td><label>
<input type="text" name="prixt" id="prixt" />
</label></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Envoyer">
</label>
</p>
</form>
</body>
</html> |