<html>
<head>
<title>JS中的级联功能</title>
<script
type="text/javascript">
//初始化省份
window.onload = function provinceInit()
{
var
node =
document.getElementById("province");
var provinceArr =
["安徽省","山东省","湖北省"];
node.options.length = 1;//设置下拉的个数
var newOption;
for(var i in
provinceArr){
//option["value值","页面显示值"]
newOption = new
Option(provinceArr[i],provinceArr[i]);
//node.add(newOption);
//循环添加到node
node.options.add(newOption);
}
}
//省份改变的时候,为city下拉赋值
function
provinceChange()
{
var
node=document.getElementById("city");
var cityList = new Array();
cityList["安徽省"] =
["安庆","芜湖","阜阳","马鞍山","亳州","池州","淮南"];
cityList["山东省"] =
["济南","青岛","淄博","枣庄","东营","烟台","潍坊"];
cityList["湖北省"] =
["武汉","宜昌","荆州","恩施","黄石","荆门","黄冈"];
var proValue =
document.getElementById("province").value;
node.options.length =
1;//清空city的下拉
var
newOption;
//注意这里是cityList[proValue]
for(var
i in
cityList[proValue]){
newOption = new
Option(cityList[proValue][i],cityList[proValue][i]);
//node.options.add(newOption);
node.add(newOption);
}
node.selectedIndex = 0;
//让select出现 "请选择城市"
}
function
cityChange()
{
var
node=document.getElementById("country");
var countryList = new Array();
countryList["安庆"] =
["望江","宿松","太湖","潜山","广安","雅安","眉山"];
countryList["芜湖"] =
["南陵","无为","繁昌","枣庄","东营","烟台","潍坊"];
var cityValue =
document.getElementById("city").value;
node.options.length =
1;//清空city的下拉,防止城市已累加的形式下拉
var
newOption;
for(var i in
countryList[cityValue]){
newOption = new
Option(countryList[cityValue][i],countryList[cityValue][i]);
node.add(newOption); //给县级下拉菜单赋值
}
}
</script>
</head>
<body>
<select
name="province" id="province"
onchange="provinceChange();">
<option
value="0">--请选择省份--</option>
</select>
<select
name="city" id="city" onchange="cityChange();">
<option
value="0">--请选择城市--</option>
</select>
<select
name="country" id="country">
<option
value="0">--请选择县级--</option>
</select>
</body>
</html>
省市县级联
时间: 2024-12-05 07:47:27
省市县级联的相关文章
省市县级联,使用ajax,并且使用ul模拟select下拉
前台代码 js //使用jquery效果展示鼠标放到省份的ul下拉展示 $("#province").hover(function(){ $("#province ul").toggle(); }) //使用jquery效果展示鼠标放到城市的ul下拉展示 $("#city").hover(function(){ $("#city ul").toggle(); }) //使用jquery效果展示鼠标放到区县的ul下拉展示 $(&
省市县级联 前端html页面
原文:https://www.cnblogs.com/hanlei525/p/9613018.html 注:里面的js.css文件:https://gitee.com/doraemonlin/data/blob/master/layui%E4%B8%AD%E7%9C%81%E5%B8%82%E5%8E%BF%E4%B8%89%E7%BA%A7%E8%81%94%E5%8A%A8.zip 原文地址:https://www.cnblogs.com/yuanmaolin/p/10929995.html
ajax + php 省市区三级联动
效果图: 数据库表: html代码 <tr><td colspan="2"> <p class="short-input ue-clear"> <label>所在地:</label> <select name="provinceid"> <?php echo Ousuclas
zTree实现地市县三级级联报错(三)
zTree实现地市县三级级联报错(三) 1.详细报错例如以下 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2014-5-11 22:37:22 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Nat
zTree实现地市县三级级联DAO接口
ProvinceDao.java: /** * @Title:ProvinceDao.java * @Package:com.gwtjs.dao * @Description:省份地市县级三级级联DAO接口 * @author:Youhaidong(游海东) * @date:2014-5-10 下午10:39:21 * @version V1.0 */ package com.gwtjs.dao; import java.util.List; import com.gwtjs.model.Pro
zTree实现地市县三级级联DAO接口实现
ProvinceDaoImpl.java: /** * @Title:ProvinceDaoImpl.java * @Package:com.gwtjs.dao.impl * @Description:省份地市县级三级级联DAO接口实现 * @author:Youhaidong(游海东) * @date:2014-5-10 下午10:40:35 * @version V1.0 */ package com.gwtjs.dao.impl; import java.util.ArrayList; i
zTree实现地市县三级级联DAO接口测试
ProvinceDaoTest.java: /** * @Title:ProvinceDaoTest.java * @Package:com.gwtjs.dao * @Description:省份地市县级三级级联DAO接口测试 * @author:Youhaidong(游海东) * @date:2014-5-10 下午11:13:43 * @version V1.0 */ package com.gwtjs.dao; import static org.junit.Assert.assertNo
zTree实现地市县三级级联Service接口
ProvinceService.java: /** * @Title:ProvinceService.java * @Package:com.gwtjs.service * @Description:省份地市县级三级级联Service接口 * @author:Youhaidong(游海东) * @date:2014-5-11 上午12:16:58 * @version V1.0 */ package com.gwtjs.service; import java.util.List; import
zTree实现地市县三级级联Service接口实现
ProvinceServiceImpl.java: /** * @Title:ProvinceServiceImpl.java * @Package:com.gwtjs.service.impl * @Description:省份地市县级三级级联Service接口实现 * @author:Youhaidong(游海东) * @date:2014-5-11 上午12:17:44 * @version V1.0 */ package com.gwtjs.service.impl; import ja