Home  >  Article  >  Web Front-end  >  Cascading problem, please solve it! ! ! _html/css_WEB-ITnose

Cascading problem, please solve it! ! ! _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:17:32822browse

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <title>MyHtml.html</title>	    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="this is my page">    <meta http-equiv="content-type" content="text/html; charset=UTF-8">        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  </head>  <script type="text/javascript">  function selectshi(sheng){  	  var s = sheng.value;  	  var shi = document.getElementById("shi");  	  if(s == 'initial'){  	  	  shi.innerHTML = '<option>请选择市</option>';  	  }else if(s == 'bj'){  	  	  shi.innerHTML = '<option>朝阳区</option><option>海淀区</option>';  	    	  }else if(s == 'hb'){  	  	  shi.innerHTML = '<option>石家庄</option><option>张家界</option><option>保定</option>';    	  }else if(s == 'ln'){  	  	  shi.innerHTML = '<option>沈阳</option><option>大连</option><option>营口</option>';    	  }else if(s == 'hn'){  	  	  shi.innerHTML = '<option>郑州</option><option>洛阳</option><option>焦作</option>';    	  }else if(s == 'js'){  	  	  shi.innerHTML = '<option>南京</option><option>徐州</option><option>苏州</option>';    	  }  }  </script>  <body>        <select id="sheng" onchange="selectshi(this)">    <option value="initial">请选择省</option>    <option value="bj">北京市</option>    <option value="sd">山东省</option>    <option value="hb">河北省</option>    <option value="ln">辽宁省</option>    <option value="hn">河南省</option>    <option value="js">江苏省</option>    </select>    <select id="shi">    <option>请选择市</option>    </select><br>  </body></html>

After selecting the province, the city behind it becomes empty


Reply to the discussion (solution)

function selectshi(sheng ){
var obj=document.getElementById("shi");
obj.options.length=0;
var s = sheng.value;
if(s == 'initial') {
obj.options.add(new Option('Please select city',''));
}else if(s=='bj'){
obj.options.add(new Option ('Chaoyang District','cy'));
obj.options.add(new Option('Haidian District','hd'));
}else if(s==hb){
obj.options.add(new Option('Shijiazhuang','sjz'));
obj.options.add(new Option('Zhangjiajie','zjj'));
}else if(s =='ln'){
.....
}
}

or:
4ec11beb6c39d0703d1751d203c17053
function selectshi(sheng){
var s = sheng.value;
var addshi="1bc555836111ef3da6c8757ad7eb2bbe"
if(s == 'initial'){ = addshi '5a07473c87748fb1bf73f23d45547ab8Please select a city4afa15d3069109ac30911f04c56f3338'; 5a07473c87748fb1bf73f23d45547ab8Haidian District4afa15d3069109ac30911f04c56f3338'; 
}else if(s == 'hb'){ 
addshi = addshi '5a07473c87748fb1bf73f23d45547ab8Shijiazhuang4afa15d3069109ac30911f04c56f3338Dalian4afa15d3069109ac30911f04c56f33385a07473c87748fb1bf73f23d45547ab8Yingkou4afa15d3069109ac30911f04c56f3338'; ; }
document.getElementById("addshi").innerHTML=addshi "18bb6ffaf0152bbe49cd8a3620346341"
}                                                 select id="sheng" onchange="selectshi(this)">
a4fdb1358958602062c45b3c0b39670ePlease select a province4afa15d3069109ac30911f04c56f3338
e5ee7d1a35169f92afed9a0c9ffd8c07 Beijing4afa15d3069109ac30911f04c56f3338
1ea06f7b1fd2e43ea8f78a8fcc53949dShandong Province4afa15d3069109ac30911f04c56f3338
1182320673f0cccb4b9334fa39c068ccHebei Province4afa15d3069109ac30911f04c56f3338
229e1a807c272eab9beb6813f1044c61Liaoning Province4afa15d3069109ac30911f04c56f3338 
4b58d477ca01a195571d285cc4946e15Henan Province4afa15d3069109ac30911f04c56f3338 
1f92c10d0b0267d954099a16e0139198 Jiangsu Province4afa15d3069109ac30911f04c56f3338 City4afa15d3069109ac30911f04c56f3338
18bb6ffaf0152bbe49cd8a3620346341
54bdf357c58b8a65c66d7c19c8e4d114

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn