Dropdown | Drop-down list two files below copy to the same file, Access through the Web path index.html see, this is through the IFRAME to achieve the dynamic update, list.php current content is relatively simple, you see through the list.php database query, and then display the query results list.
Index.html
<body>
<form name= "Myfrm" >
<select name= "Mlist" >
<option value= "0" > Please select ...</option>
<option value= "Beijing" > Beijing </option>
<option value= "Tonghua" > Tonghua </option>
</select>
<select name= "Slist" >
</select>
<iframe id= "Frame" src= "list.php?city=" style= "Display:none"; ></iframe>
<script language= "JavaScript" >
function changes () {
Frame.location.href = "list.php?city=" + document.myfrm.mlist.value;
}
</script>
</form>
</body>
list.php
<?php
$data = Array ("Beijing" =>array ("Xiao Qiang", "Prosperous wealth", "Xiao Qiang his father"),
"Tonghua" =>array ("Xiao Wen", "Xiao Song", "their son");
$city = $_get["City"];
$result = $data [$city];
$str = "<script language=\" javascript\ ">list = parent.document.myfrm.slist;list.length = 0;";
if ($result ==null)
$str. = "TMP = new Option (\ ... \" \ "\"); list.options[0] = tmp; ";
Else
foreach ($result as $i => $value)
$str. = "TMP = new Option (\" {$value}\ ", \" {$value}\ "); list.options[$i] = tmp;";
$str. = "</script>";
Echo $str;
?>