Javawscript Three Level menu implementation principle _javascript Skill

Source: Internet
Author: User
Provinces: Please selectShandong Province
City: = = Please select = =WeihaiDezhouBinzhou
District:

= = Please select township = =WeihaiWendengRongchengRushan

Provinces, cities, counties Data Structures: "Name, parent class ID, current ID"

Onchange= "Changelocation2 (document.editform.smalllocation.options[ Document.editform.smalllocation.selectedindex].value) "

According to SelectedIndex, get the parent class ID of the next level associated menu,

Copy Code code 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 (' = = Please select = = ', ');
document.getElementById ("Dlmc0"). Options[0] = new Option (' = = Please select = = ', ');

alert (LocationID);
var Locationid=locationid;
var i;
Document.editform.smalllocation.options[0] = new Option (' = = Please 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]);
}
}
}

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.