<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="" name="theform">
<select name="province" onchange="getCity()">
<option value = "0">请选择所在的省份</option>
<option value="1">浙江省</option>
<option value="2">山东省</option>
<option value="3">广东省</option>
<option value="4">甘肃省</option>
</select>
<select id="city" onchange="getQu()">
<option value = "0">请选择所在的城市</option>
</select>
<select name = "qu">
<option value = "0">请选择所在的县区</option>
</select>
</form>
<script>
var city=[
["杭州市","温州市","宁波市","绍兴市"],
["济南市","青岛市","济宁市","潍坊市"],
["广州市","潮阳","澄海","潮州"],
["兰州市","白银","敦煌","定西"]
];
var qu=[
[
["杭州一区","杭州二区"],
["温州一区","温州二区"],
["宁波一区","宁波二区"],
["绍兴一区","绍兴二区"]
],
[
["济南一区","济南二区"],
["青岛一区","青岛二区"],
["济宁一区","济宁二区"],
["潍坊一区","潍坊二区"],
],
[
["广州一区","广州二区"],
["潮阳一区","潮阳二区"],
["澄海一区","澄海二区"],
["潮州一区","潮州二区"],
],
[
["兰州一区","兰州二区"],
["白银一区","白银二区"],
["敦煌一区","敦煌二区"],
["定西一区","定西二区"],
]
];
var getProvince = document.forms['theform'].province;
var City = document.forms[0].city;
var Qu = document.forms[0].qu;
function getCity(){
Qu.length = 1;
City.length = 1;
var getSelectIndex = getProvince.selectedIndex;
var proCity = city[getSelectIndex-1];
console.log( proCity)
for( var i=0; i<proCity.length; i++){
City[i+1] = new Option(proCity[i],getSelectIndex)
}
}
function getQu(){
var getSelectIndex = getProvince.selectedIndex;
var getCitySelectedIndex = City.selectedIndex;
console.log( getCitySelectedIndex )
var cityQu = qu[getSelectIndex - 1][ getCitySelectedIndex - 1];
console.log( cityQu )
for( var i=0; i<cityQu.length; i++){
Qu[i+1] = new Option(cityQu[0],getCitySelectedIndex)
}
}
</script>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
· 现代计算机视觉入门之:什么是视频
· 你所不知道的 C/C++ 宏知识
· 不到万不得已,千万不要去外包
· C# WebAPI 插件热插拔(持续更新中)
· 会议真的有必要吗?我们产品开发9年了,但从来没开过会
· 【译】我们最喜欢的2024年的 Visual Studio 新功能
· 如何打造一个高并发系统?