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
| <?
$query = "SELECT * FROM a_departement ORDER BY id_departement";
$sql = mysql_query($query);
$query_fr = "SELECT * FROM a_region WHERE pays='france' ORDER BY id_region";
$sql_fr = mysql_query($query_fr);
$query_ch = "SELECT * FROM a_canton ORDER BY id_canton";
$sql_ch = mysql_query($query_ch);
?>
<script language="javascript">
<!--
function test(form,list)
{
list.options.length=0;
if(form.pays.value == "0")
{
var o=new Option("Région/Canton*","0");
form.region.options[form.region.options.length]=o;
}else if(form.pays.value != "3")
{
var o=new Option("Choisissez la région","0");
form.region.options[form.region.options.length]=o;
}else if(form.pays.value == "3")
{
var o=new Option("Choisissez le Canton","0");
form.region.options[form.region.options.length]=o;
}
if(form.pays.value < "2")
{
form.dept.options.length=0;
var o=new Option("Département","0");
form.dept.options[form.dept.options.length]=o;
}
if(form.pays.value == "1")
{
<?php
while($data_fr=mysql_fetch_array($sql_fr))
{
print ("var o=new Option(\"".$data_fr['region']."");
print("\",\"".$data_fr['id_region']."\");\n");
print "form.region.options[form.region.options.length]=o;\n";
}
?>
}
if(form.pays.value == "2")
{
form.dept.options.length=0;
var o=new Option("Non concerné","0");
form.dept.options[form.dept.options.length]=o;
var o=new Option("Bruxelles-Capitale","25");
form.region.options[form.region.options.length]=o;
var o=new Option("Flamande","26");
form.region.options[form.region.options.length]=o;
var o=new Option("Wallonne","27");
form.region.options[form.region.options.length]=o;
}
if(form.pays.value == "3")
{
form.dept.options.length=0;
var o=new Option("Non concerné","0");
form.dept.options[form.dept.options.length]=o;
<?
while($data_ch=mysql_fetch_array($sql_ch))
{
print ("var o=new Option(\"".$data_ch['nom']."");
print("\",\"".$data_ch['id_canton']."\");\n");
print "form.region.options[form.region.options.length]=o;\n";
}
?>
}
}
function dep(form,list)
{
if(form.pays.value == "1")
{
list.options.length=0;
<?
while($data=mysql_fetch_array($sql))
{
print "if(form.region.value == \"".$data['id_region']."\")\n";
print "{\n";
print ("var o=new Option(\"".$data['departement']."");
print("\",\"".$data['numero']."\");\n");
print "form.dept.options[form.dept.options.length]=o;\n}\n";
}
?>
}
}
//-->
</script>
<select name="pays" align="top" OnChange="test(this.form,this.form.region)">
<option value="0">Choix Pays</option>
<option value="1">France</option>
<option value="2">Belgique</option>
<option value="3">Suisse</option>
</select>
<select name="region" align="top" OnChange="dep(this.form,this.form.dept)">
<option value="0">Région/Canton</option>
</select>
<select name="dept">
<option value="Liste vide">Département</option>
</select> |
Partager