JavaScript and provincial level two Cascade menu

Source: Internet
Author: User
Tags eval
Tip: You can modify some of the code before running

<p> This JavaScript allows users to select a region and second place in the world, and then in the region of the country, in particular the Pull-down menu changes </p> <script language= "JavaScript" > <!-- Begin var africaarray = new Array (' Select country ', ', true,true) ', ' (' Ethiopia ') "," (' Somalia ') "," (' South Africa ') "," (' other ') "); var middleeastarray = new Array (' Select Country ', ', ', True,true) "," (' Egypt ') "," (' Iran ') "," (' Israel ') "," (' Kuwait ') ", "(' Lebanon ')", "(' Morocco ')", "(' Saudi Arabia ')", "(' Syria ')", "(' Turkey ')", "(' U. A. Emirates ')", "(' Other ')"); var asiaarray = new Array (' Select Country ', ', ', true,true) ', ' (' Armenia ') "," (' Bangladesh ') "," (' Cambodia ') "," (' The ' ) "," (' India ') "," (' Indonesia ') "," (' Japan ') "," (' Malaysia ') "," (' Myanmar ') "," (' Nepal ') "," (' Pakistan ') "," (" Philippines ') "," (' Singapore ') "," (' South Korea ') "," (' Sri Lanka ') "," (' Taiwan ') "," (' Thailand ') "," (' Uzbekistan ') "," ( ' Vietnam ') "," (' Other ') "); var europearray = new Array (' Select Country ', ', ', True,true) "," (' Albania ') "," (' Austria ') "," (' Belarus ') "," (' Belgium ' ) "," (' Bosnia ') "," (' BUlgaria ') "," (' Croatia ') "," (' Cyprus ') "," (' Czech Rep. ') "(' Denmark ')", "(' Estonia ')", "(' Finland ')", "(' France ')", " (' Germany ') "," (' Greece ') "," (' Hungary ') "," (' Iceland ') "," (' Ireland ') "," (' Italy ') "," (' Latvia ') "," (' Liechtenstein ') "." ) "," (' Lithuania ') "," (' Luxembourg ') "," (' Macedonia ') "," (' Malta ') "," (' Monaco ') "," (' Netherlands ') "," (' Norway ') "," ( ' Poland ') "," (' Portugal ') "," (' Romania ') "," (' Russia ') "," (' Slovakia ') "," (' Slovenia ') "," (' Spain ') "," (' Sweden ') "," ( ' Switzerland ') "," (' Ukraine ') "," (' United Kingdom ') "," (' Other ') "); var australiaarray = new Array (' Select Country ', ', ', True,true) "," (' Australia ') "," (' New Zealand ') "," (' Other ') "); var lamericaarray = new Array (' Select Country ', ', true,true) ', ' (' Costa Rica ') ', ' (' Cuba ') ', ' (' El Salvador ') ', "(' Guat Emala ') "," (' Haiti ') "," (' Jamaica ') "," (' Mexico ') "," (' Panama ') "," (' Other ') "); var namericaarray = new Array (' Select Country ', ', ', True,true) "," (' Canada ') "," (' USA ') "," (' Other ') "); var samericaarray = new Array (' SeLect country ', ', True,true) "," (' Argentina ') "," (' Bolivia ') "," (' Brazil ') "," (' Chile ') "," (' Colombia ') "(' Ecuador ')" "," (' Paraguay ') "," (' Peru ') "," (' Suriname ') "," (' Uruguay ') "," (' Venezuela ') "," (' Other ') "); function Populatecountry (inform,selected) {var Selectedarray = eval (selected + "Array"); while (selectedarray.length ; InForm.country.options.length) {inform.country.options[(inform.country.options.length-1)] = null;} for (Var i=0; ; Selectedarray.length; i++) {eval ("inform.country.options[i]=" + "new Option" + Selectedarray[i]);} if (Inform.region.options[0].value = = ") { inform.region.options[0]= null; if (navigator.appname = = ' Netscape ') {if (parseint (navigator.appversion) < 4) {window.history.go (0);} else {if (Navigator.platform = = ' Win32 ' | | | navigator.platform = = ' Win16 ') {window.history.go (0); }}} function Populateusstate (inform,selected) {var statearray = new Array (' Select State ', ' True,true) "," (' AlabAma ') "," (' Alaska ') "," (' Arizona ') "," (' Arkansas ') "," (' California ') "," (' Colorado ') "," (' Connecticut ') "," (" Delaware ') "," (' Columbia ') "," (' Florida ') "," (' Georgia ') "," (' Hawaii ') "," (' Idaho ') "," (' Illinois ') "," (' Indiana ') "," (' Iowa ') "," (' Kansas ') "," (' Kentucky ') "," (' Louisiana ') "," (' Maine ') "," (' Maryland ') "," (' Massachusetts ') "," (" Michigan ') "," (' Minnesota ') "," (' Mississippi ') "," (' Missouri ') "," (' Montana ') "," (' Nebraska ') "," (' Nevada ') "," (' New Hampshire ') "," (' New Jersey ') "," (' New Mexico ') "," (' New York ') "," (' North Carolina ') "," (' North Dakota ') "," (' Ohio ') "," ( ' Oklahoma ') "," (' Oregon ') "," (' Pennsylvania ') "," (' Rhode Island ') "," (' South Carolina ') "," (' South Dakota ') "," (" Tennessee ') "," (' Texas ') "," (' Utah ') "," (' Vermont ') "," (' Virginia ') "," (' Washington ') "," (' West Virginia ') "," (' Wisconsin ') "," (' Wyoming ') "); if (selected = = ' USA ') {for (Var i=0 i < statearray.length; i++) {eval ("inform.country.options[i]=" + "new Option" + Statearray[i]); } if (navigator.appname = = 'Netscape ') {if (parseint (navigator.appversion) < 4) {window.history.go (0)} else {if (Navigator.platform = = ' Wi N32 ' | | Navigator.platform = = ' Win16 ') {window.history.go (0)}}}} else {} if (selected = = ' other ') {NEWC Ountry = ""; while (Newcountry = = "") {newcountry=prompt ("Please enter the name of your country.", "");} if (newcountry!= null) {inform.country.options[(inform.country.options.length-1)]=new Option (newcountry,newcountry , true,true); Inform.country.options[inform.country.options.length]=new Option (' Other, not listed ', ' other '); } if (Inform.country.options[0].text = = ' Select country ') {inform.country.options[0]= null; }//End--> </script> <form name= "globe" > <select name= "Region" onchange= "Populatecountry" ( Document.globe,document.globe.region.options[document.globe.region.selectedindex].value) "> <option Selected Value= ' >select region</option> <option value= ' Asia ' >Asia</option> <Option value= ' Africa ' >Africa</option> <option value= ' Australia ' >Australia</option> <option Value= ' Europe ' >Europe</option> <option value= ' middleeast ' >middle east</option> Value= ' Lamerica ' >latin america</option> <option value= ' NAmerica ' >north America</option> < Option value= ' SAmerica ' >south america</option> </select> <select name= ' country ' onchange= ' Populateusstate (document.globe,document.globe.country.options[document.globe.country.selectedindex].text) "> <option value= ' ><--------------------</option> </select> </form>
Tip: You can modify some of the code before running
Related Article

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.