JS Two-level Linkage drop-down List menu effect

Source: Internet
Author: User

The article provides a JS two-level Linkage Drop-down List menu Effect Oh, this is a city linkage menu effect, if you are the JS linkage menu, you can come in and see, this is the use of an array to save all the city, and then select the Drop-down box to put the city, each two-dimensional array is a pair of cities.

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> New Document </title>
<script language= "Web Effects" type= "Text/javascript" >
<!--
Define a two-dimensional array in the order of the Province Drop-down list box to correspond the city list to the province
var city=[
["Beijing", "Tianjin", "Shanghai", "Chongqing"],//municipality
["Nanjing", "Suzhou", "Nantong", "Changzhou"],//Jiangsu province
["Fuzhou", "Fu'an", "Longyan", "nanping"],//Fujian province
["Guangzhou", "Chaoyang", "Chaozhou", "Chenghai"],//Guangdong province
["Lanzhou", "Silver", "Dingxi", "Dunhuang"]//Gansu Province
];

Function getcity () {
 //obtains a reference to the body province and city drop-down list box
 var sltprovince=document.forms[theform "].elements[" Province "];
 var sltcity=document.forms["theform"].elements["City"];
 //Gets the list of cities that correspond to the provinces
 var provincecity=city[sltprovince.selectedindex-1];
 
 // Empty the City Drop-down list box, leaving only the first hint option
 sltcity.length=1
 //the city to the city selection box
 for (Var i=0;i< provincecity.length;i++) {
  //creates a new option object and adds it to the City drop-down list box
  sltcity[i+1]=new option ( Provincecity[i],provincecity[i]);
 }
}
//-->
</script>
<body>

<form action= "somepage.asp tutorial" name= "theform"
<select name= "province" onchange= "Getcity ()"
 <option value= "0" > Please select the province </option>
 <option value= "municipality" > municipality </option>
 <option value= "Jiangsu province" > Jiangsu province </option>
 <option value= "Fujian province" > Fujian province </option>
 <option value= "Guangdong province" > Guangdong province </option>
 <option value= "Gansu province" > Gansu province </option>
< /select>
<select name= "City"
 <option value= "0" > Please choose your town </option>
</select
</form>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.