Simple js Code to achieve selece level-2 Association (recommended)

Source: Internet
Author: User

The following is the html code:
Copy codeThe Code is as follows:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<Meta name = "Generator" CONTENT = "EditPlus">
<Meta name = "Author" CONTENT = "">
<Meta name = "Keywords" CONTENT = "">
<Meta name = "Description" CONTENT = "">
</HEAD>
<! -- By sundful starting -->
<BODY>
<Script language = "JavaScript">

Var subcat = new Array ();
Subcat [0] = new Array ('Chinese', 'English ', 'English ')
Subcat [1] = new Array ('Chinese', 'French ', 'French ')
Subcat [2] = new Array ('English ', 'Chinese', 'Chinese ')
Subcat [3] = new Array ('French ', 'Chinese', 'Chinese ')
Function changeselect1 (locationid)
{
Document. form1.s2. length = 0; // initialize the drop-down list to clear the drop-down data
Document. form1.s2. options [0] = new Option ('= select =', ''); // give the first value
For (I = 0; I <subcat. length; I ++) // leader = 20
{
If (subcat [I] [0] = locationid) // [0] [1] First column and second column
{Document. form1.s2. options [document. form1.s2. length] = new Option (subcat [I] [1], subcat [I] [2]);} // create an option
// The first time length = 1 because there is = Please select =
// When I = 9, there are 11 length = 10 values because subcat [I] [0] = locationid is blocked and then written.
}
}
</Script>

<Form name = "form1" method = "post" runat = "server">
Secondary linkage:

<Select name = "s1" onChange = "changeselect1 (this. value)">
<Option >== select ==</option>
<Option value = ""> Chinese </option>
<Option value = "English"> English </option>
<Option value = "English"> French </option>
</Select>

<Select name = "s2">
<Option >== select ==</option>
</Select>
</Form>
<! -- By sundful ending -->
</BODY>
</HTML>

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.