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
| <script langage="JavaScript">
function Choix(form){
var txt=new Array();
var txt_nb=new Array();
i = form.Glob.selectedIndex;
if (i==0){
return;
}
<?php
mysql_connect("localhost", "root", ""); // Connexion à MySQL
mysql_select_db("rs"); // Sélection de la base rs
$res1 = mysql_query("SELECT DISTINCT Nomfamille FROM famille");
$cpt_glob=0;
while($row1= mysql_fetch_assoc($res1)){
$cpt_glob++;
$sel = mysql_query("SELECT DISTINCT NomSousFamille FROM sousfamille where NomSousFamille='".$row1["NomFamille"]."' ORDER BY 1") or die(mysql_error());
$cp=0;
while($sel1 = mysql_fetch_assoc($sel)){
$cp++;
if ($cp==1) echo "txt[".$cpt_glob."]=new Array();";
echo "txt[".$cpt_glob."][".$cp."]='".$sel1["NomFamille"]."';";
#echo "<option value='".$sel1["NomFamille"]."'>".$sel["NomFamille"]."</option>";
}
echo "txt_nb[".$cpt_glob."]=".$cp.";";
}
?>
form.Type.options.length = 0;
form.Type.selectedIndex = 0 ;
form.Type.options[0]=new Option("--Choix--",0);
for(c=1;c<=txt_nb[i];c++) {
form.Type.options[c]=new Option(txt[i][c],c);
}
}
</script>
<form>
<fieldset style="width: 800px">
<legend>Liste liées</legend>
<label>Famille</label>
<select name="famille" onChange='Choix(this.form)'>
<option>--Choix --</option>
<?php
mysql_connect("localhost", "root", ""); // Connexion à MySQL
mysql_select_db("rs"); // Sélection de la base rs
$res = mysql_query("SELECT DISTINCT NomFamille FROM famille");
while($row = mysql_fetch_assoc($res)){
echo "<option value='".$row["NomFamille"]."'>".$row["NomFamille"]."</option>";
}
?>
</select>
<label>Sous Famille</label>
<select name="sousfamille">
<option>--Choix--</option>
<?php
mysql_connect("localhost", "root", ""); // Connexion à MySQL
mysql_select_db("rs"); // Sélection de la base rs
$sel = mysql_query("SELECT DISTINCT NomSousFamille FROM sousfamille where NomSousFamille='".$row2["NomFamille"]."' ORDER BY 1") or die(mysql_error());
$cp=0;
while($sel1 = mysql_fetch_assoc($sel)){
$cp++;
if ($cp==1) echo "txt[".$cpt_glob."]=new Array();";
echo "txt[".$cpt_glob."][".$cp."]='".$sel1["NomSousFamille"]."';";
echo "<option value='".$sel1["NomSousFamille"]."'>".$sel1["NomSousFamille"]."</option>";
}
?>
</select>
</fieldset>
</form>
</tr></table> |