jquery Multi-level linkage (Ajax search database)

Source: Internet
Author: User

/ID represents the Subordinate drop-down box Id,citycode represents the parent menu code, all level menu in the same table, background loading is to put the menu has been added to the map cache ....

1 //The ID represents the subordinate drop-down box Id,citycode represents the parent menu code, and all level menus are in the same table,2 functionGetcitys (citycode,id) {3$ ("#" +id+ "option:gt (0)"). Remove ();4             if(Citycode)5             {6$ ("#loading"). Show ();//Displays the prompt layer being loaded7                 varLoadurl= "/sfss/sysman2012/loadcitys.do";8                 varLoaddata= "&key=" +citycode+ "&dt=" +NewDate (). GetTime ();9 $.ajax ({Ten Url:loadurl, One Data:loaddata, AMethod: ' POST ', -DataType: ' JSON ', -Successfunction(data) { the                             if(data!=NULL&&data.citys.length>0) -                             {    -$("#"+ID). Show (); -$ (Data.citys). each (function(index,city) { +$ ("#" +id). Append ("<option value=" "+city.key+" ' > "+city.value+" </option> ");  -                                 }); +                             } A                             Else at                             { -$("#"+ID). Hide (); -                             } -$ ("#loading"). Hide (); -                         } -                     }); in             } -             Else to             {  +$("#"+ID). Hide (); -             } the         } *$(function(){//The code is used to modify the page, after entering the birthplace, birthplace, place of residence, unified loading $             //Initialize the list of cities under the provincial levelPanax Notoginseng$ ("select[name$= ' province ')". each (function(){ -                 //if a provincial drop-down box has an initial value, the corresponding city-level drop-down box is displayed the                 if( This. Value) +                      This. onchange (); A             }); the         }); +   -   $   $ HTML -     //Province -<select onchange= "Getcitys (this.value, ' nativeplacecity ')" Name= "Nativeplaceprovince" > the     //City -<select style= "Display:none;" Name= "nativeplacecity" id= "nativeplacecity" >

jquery Multi-level linkage (Ajax search database)

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.