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
|
<html>
<head>
<style>
.hide
{
display: none;
}
.show
{
display: block;
}
</style>
<script type="text/javascript">
var currentform="";
function doForms(form) {
if (currentform!="") {
var fm = document.getElementById(currentform);
if (typeof(fm) != undefined){
fm.className="hide";}}
var itm = form.selectform[form.selectform.selectedIndex].value;
currentform=itm;
if (itm!="") {
fm = document.getElementById(itm);
if (typeof(fm) != undefined) {
fm.className="show";
currentform=""; } } }
</script>
</head>
<body>
<?php
$host = "********";
$user = "*****";
$bdd = "******";
$passwd = "*******";
mysql_connect($host, $user,$passwd) or die("erreur de connexion au serveur");
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
$query = "SELECT * FROM db_cpu";
$result = mysql_query($query);
$i=0;
?>
<form name="selectsinging">
<SELECT name="selectform" onchange="doForms(this.form)">
<OPTION value="" selected>Produit 1</option>
<OPTION value="">----------</option>
<?php while($row = mysql_fetch_row($result)){
$cel[$i]=$row;
echo '<option value="'.$i.'">'.$cel[$i][1].'</option>';
$i++;}?>
</select>
</form>
// ci dessous je souhaite récupérer le champ "value" du "select" sélectionné.
<div id="<?php echo $i ; ?>" class="hide" style="border: 1px solid #000000"><?php echo $cel[$i][1]; ?></div>
</body>
</html> |
Partager