JS-practical two-level linkage menu

Source: Internet
Author: User




Source code:


<HTML> <br/> <pead> <br/> <MCE: Script Type = "text/JavaScript"> <! -- <Br/> var array = new array (); <br/> array ["China"] = new array ("Shanghai", "Beijing", "Hongkong ", "Taiwan"); // China <br/> array ["USA"] = new array ("New York "); // us <br/> array ["Japan"] = new array ("litter toyko", "motherfuck "); // Japanese tribe -----> name changed from Japanese Empire </P> <p> function level () <br/> {<br/> var c = document. getelementbyid ("C"); <br/> C. length = 0; <br/> var P = document. getelementbyid ("p "). value; // obtain the selected option value <br/> for (VAR r = 0; r <array [p]. length; r ++) // array [p]: Retrieves an Array Based on the selected country <br/>{< br/> var Options = document. createelement ("option"); <br/> options. innerhtml = array [p] [r]; // sets the text <br/> options. value = array [p] [r]; // set the actual value <br/> C. appendchild (options); // Add the option value to select <br/>}</P> <p> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body> <br/> <select id = "p" width = "10" onchange = "level () "> // country <br/> <option value =" China "> China </option> <br/> <option value =" USA "> USA </option> <br/> <option value = "Japan"> litter Japan </option> <br/> </SELECT> </P> <p> <select id = "C" Width = "10"> // city <br/> </SELECT> <br/> </body> <br/> </ptml>

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.