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
|
// ici on declare les fonctions qui vont remplir les Select
<script language="javascript">
function fill_prov(){
addOption(document.search.idprov, "0", "", "");
addOption(document.search.idprov, "1", "Tenerife", "");
addOption(document.search.idprov, "2", "Gran Canaria", "");
}
function fillmuni(){
removeAllOptions(document.search.idmuni);
addOption(document.search.idmuni, "0", "Toutes", "");
if (document.search.idprov.value == "1"){
addOption(document.search.idmuni,"1", "Arona");
addOption(document.search.idmuni,"2", "Fasnia");
addOption(document.search.idmuni,"3", "Adeje");
}
if (document.search.idprov.value == "2"){
addOption(document.search.idmuni,"4", "zone a");
addOption(document.search.idmuni,"5", "zone b");}
}
function addOption(selectbox, value, text ){
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
function removeAllOptions(selectbox){
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
</script>
//ici on remplis les selects avec onload
<body BGCOLOR="#C8BFA1" onload="fill_prov();">
//on ouvre le formulaire
<form name="search" action="chercher.php" method="get">
//premier tableau
<table><tr><td>
<select name="idprov" onchange="fillmuni();"></select>
</td></tr></table>
//second tableau
<table><tr><td>
<select name="idmuni"></select>
</td></tr></table>
</form> |
Partager