JavaScript-Provinces Cascade effect instances

Source: Internet
Author: User

Title
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" ><html><head><meta http-equiv="Content-type" Content="text/html; Charset=utf-8 "><title>Provincial Cascade Effect</title><script type="Text/javascript">     function selectcity(){        varObjprovince=document.getelementbyid ("province");varObjcity=document.getelementbyid ("City");//objcity.length=0;//Empty drop-down list optionsObjcity.options.length=0;Switch(Objprovince.value) { Case "1": Objcity.add (NewOption ("Nanjing","1"),NULL); Objcity.add (NewOption ("Suzhou","2"),NULL); Objcity.add (NewOption ("Wuxi","3"),NULL); Objcity.add (NewOption ("Nantong","4"),NULL); Break; Case "2": Objcity.add (NewOption ("Jinan","1"),NULL); Objcity.add (NewOption ("Qingdao","2"),NULL); Objcity.add (NewOption ("Sunshine","3"),NULL); Objcity.add (NewOption ("Yantai","4"),NULL); Break; Case "3": Objcity.add (NewOption ("Guangzhou","1"),NULL); Objcity.add (NewOption ("Dongguan","2"),NULL); Objcity.add (NewOption ("Shenzhen","3"),NULL); Objcity.add (NewOption ("Foshan","4"),NULL); Break; }    }</script></head><body>    <form Action= " method="post ">        <select id="province" onchange="selectcity ();" >            <option value="0">--Provinces--</option>            <option value="1">Jiangsu Province</option>              <option value="2">Shandong Province</option>                          <option value="3">Guangdong Province</option>                          <option value="4">Zhejiang Province</option>              <option value="5">Yunnan Province</option>                                          </Select>        <select id="City">            <option value="0">--City--</option>        </Select>    </form></body></html>
Arrays-Provinces and cities Cascade
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" ><html><head><meta http-equiv="Content-type" Content="text/html; Charset=utf-8 "><title>Arrays-Provinces and cities Cascade</title><script type="Text/javascript">    //define Province City array    varprovinces=New Array(); provinces["Jiangsu Province"]=["Nanjing","Suzhou","Xuzhou","Suqian"]; provinces["Shandong Province"]=["Jinan","Rizhao","Yantai","Qingdao"]; provinces["Zhejiang province"]=["Hangzhou City","Ningbo","Obligation City","Wenzhou"]; provinces["Guangdong province"]=["Guangzhou","Foshan","Dongguan","Zhuhai"];//Initialize province information     function init(){    varObjprovince=document.getelementbyid ("province"); for(varPinchProvinces) {Objprovince.add (NewOption (P,p),NULL); }    }//Switch Cities     function changecity(){        varObjprovince=document.getelementbyid ("province");varObjcity=document.getelementbyid ("City"); Objcity.length=0;//Mode one:/ * for (Var p in provinces) {if (P==objprovince.value) {for (Var C in province                    S[p]) {Objcity.add (new Option (provinces[p][c],provinces[p][c]), NULL); }                }            }   */          //Mode two:             for(varPinchProvinces[objprovince.value]) {Objcity.add (NewOption (Provinces[objprovince.value][p],provinces[objcity.value]),NULL); }} Window.onload=init;</script></head><body>    <form Action= " method="post ">        <select id="province" onchange="changecity ();" >            <option value="0">--Provinces--</option>        </Select>        <select id="City">            <option value="0">--City--</option>        </Select>    </form></body></html>

JavaScript-Provinces cascade effect instances

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.