今天搞了一个国家,省,市,地区四级联动免刷新菜单
代码使用js编写
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript" src="common/city.js"></script>
<script language="javascript" src="common/selectcity.js"></script>
<style>
.select2
{
border: 1px solid #7B7D7B;
97px;
height: 18px;
clip: rect( 0px, 129px, 18px, 0px );
overflow: hidden;
}
.select1
{ FONT-SIZE: 12px;
font-family: Verdana, Arial, Helvetica, sans-serif, "宋体";
position: relative;
left: -2px;
top: -2px;
100px;
line-height: 16px; color: #444444;
border-style: none;
border- 0px;
}
</style>
</head>
<script language="javascript">
function onChangeCity(formName,countryName,provinceName,cityName,areaName){
var countryValue = eval(formName+"."+countryName).value;
var provinceValue = eval(formName+"."+provinceName).value;
if (countryValue != 0){
if (provinceValue != 0){
city.innerHTML = showCitySelect(formName,countryName,provinceName,cityName,areaName,countryValue,provinceValue,'');
var cityValue = eval("add3code_"+provinceValue);
if (cityValue == ""){
area.innerHTML = showAreaSelect(areaName,provinceValue,'');
}
}else{
city.innerHTML = showCitySelect(formName,countryName,provinceName,cityName,areaName,countryValue,'','');
}
}else{
city.innerHTML = showCitySelect(formName,countryName,provinceName,cityName,areaName,'','','');
}
}
function onChangeArea(formName,cityName,areaName){
var cityValue = eval(formName+"."+cityName).value;
if (cityValue != ""){
area.innerHTML = showAreaSelect(areaName,cityValue,'');
}
}
function initCity(formName,countryName,provinceName,cityName,areaName){
city.innerHTML = showCitySelect(formName,countryName,provinceName,cityName,areaName,'1','19','190');
area.innerHTML = showAreaSelect(areaName,'190','');
}
</script>
</head>
<body onLoad="javascript: initCity('pub_info','country','provetion','city','area');">
<form action="" method="post" name="pub_info">
<span id="city"></span><span id="area"></span>
</body>
</html>