/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)