<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style type="text/css">
</style>
<body>
省:
<select name="" id="sheng" onchange="selecShi()">
<option value="">请选择省份</option>
<option value="0">河北</option>
<option value="1">山东</option>
<option value="2">河南</option>
<option value="3">山西</option>
</select>
市:
<select name="" id="shi">
<option value="">请选择市</option>
</select>
</body>
<script type="text/javascript">
var arr=[]
arr[0]=["秦皇岛","保定","石家庄","唐山"]
arr[1]=["济南","临沂","青岛","威海"]
arr[2]=["洛阳","郑州","开封","周口"]
arr[3]=["太原","大同","运城","忻州"]
function selecShi(){
var sheng=document.getElementById("sheng").value
// 获取所选项的value值[0,1,2,3]
// console.log(sheng)
var currentShi=arr[sheng]
var shi=document.getElementById("shi")
var str="<option value=''>请选择市</option>"
for(var i=0;i<currentShi.length;i++){
str+="<option value=''>"+currentShi[i]+"</option>"
}
shi.innerHTML=str
}
</script>
</html>