Implementation principle of javawscript three-level menu

Source: Internet
Author: User

Province: Select Shandong
City: = Select =Weihai CityDezhou CityBinzhou City
Districts and counties:

= Select Villages and Towns =WeihaiWendengRongchengRushan

Province, city, and district/county Data Structure: [name, parent class ID, current ID]

OnChange = "changelocation2 (document. editForm. smalllocation. options [document. editForm. smalllocation. selectedIndex]. value )"

Obtain the parent class ID of the next level association menu based on selectedIndex,
Copy codeThe Code is as follows:
Function changelocation (locationid)
{
Document. editForm. smalllocation. length = 0;
// Document. editForm. dlmc0.length = 0;
Document. getElementById ("dlmc0"). length = 0;
// Document. editForm. dlmc0.options [0] = new Option ('= select = ','');
Document. getElementById ("dlmc0"). options [0] = new Option ('= select = ','');

// Alert (locationid );
Var locationid = locationid;
Var I;
Document. editForm. smalllocation. options [0] = new Option ('= select = ','');
For (I = 0; I <onecount; I ++)
{
If (subcat [I] [1] = locationid)
{
Document. editForm. smalllocation. options [document. editForm. smalllocation. length] = new Option (subcat [I] [0], subcat [I] [2]);
}
}
}

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.