单选.html
<html>
<script>
function singleselect(str)
{
var xmlhttp;
if(str.length == 0)
{
document.getElementById("sing").innerHTML="";
return;
}
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhtttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4)
{
document.getElementById("sing").innerHTML = xmlhttp.responsetext;
}
}
xmlhttp.open("POST","singleselect.php?s=" +str,true);
xmlhttp.send();
}
</script>
<style>
div { font-family:verdana; font-size:13px; margin-left:400px; margin-top:100px; }
</style>
<body>
<div>
Select a country :
<select onchange="document(this.value)">
<option>Select a country</option>
<option value="0">INDIA</option>
<option value="1">United States of America</option>
<option value="2">United Kingdom</option>
<option value="3">Australia</option>
</select>
</div>
<div id="sing"></div>
</body>
</html>
单选.php
<?php
$store[0] = "Please select a country";
$store[1] = "Andhra Pradesh";
$store[2] = "New York";
$store[3] = "London";
$store[4] = "Austraila";
$s = $_REQUEST['s'];
?>
当我单击一个国家/地区时,应显示与该国家/地区相关的州列表,我希望在 php 中完成静态但使用数据库。因为我是 jQuery 和 AJAX。我需要你的指导。