Three-level linkage: is a common type in the registry, the city will change according to the province, the district will change according to the city changes, the use is also very convenient, in the required interface reference Div can
Main Page: Write a good div, quote JS can
Note: must be referenced under jquery
San.js page: Main content on the JS page to write good
Specific steps:
1. Write three drop-down lists in Div, which are province, city, and district
2. Fill in the content: Select the time of the province to change the city and the district, when the city is selected to change the area
3. How to write: Fill in the content
//JavaScript Document$ (document). Ready (function(e) {//write a div with three drop-down lists$ ("#sanji"). HTML ("<select id= ' sheng ' ></select><select id= ' shi ' ></select><select id= ' qu ' ></select> '); //fill content (Result) //1. Fill the provinceFillsheng (); //2. Filling the cityFillshi (); //3. Filling areaFillqu (); //if the province is selected to change, fill in the city and the District$ ("#sheng"). Change (function(){ //Change the cityFillshi (); //Change ZoneFillqu (); }) //If the city is selected for change, go to fill the area$ ("#shi"). Change (function(){ //Change ZoneFillqu (); }) //ways to fill the province functionFillsheng () {//Find the parent code varPcode = "0001"; $.ajax ({async:false, URL:"Chuli.php", Data:{pcode:pcode}, type:"POST", DataType:"TEXT", Success:function(data) {varstr = ""; varHang = Data.split ("|"); for(vari=0;i) { varLie = Hang[i].split ("^"); STR+ = "<option value=" "+lie[0]+" > "+lie[1]+" </option> "; } $("#sheng"). html (str); } }); } //methods of filling the city functionFillshi () {varPcode = $ ("#sheng"). Val (); $.ajax ({async:false, URL:"Chuli.php", Data:{pcode:pcode}, type:"POST", DataType:"TEXT", Success:function(data) {varstr = ""; varHang = Data.split ("|"); for(vari=0;i) { varLie = Hang[i].split ("^"); STR+ = "<option value=" "+lie[0]+" > "+lie[1]+" </option> "; } $("#shi"). html (str); } }); } //methods for populating the area functionFillqu () {varPcode = $ ("#shi"). Val (); $.ajax ({async:false, URL:"Chuli.php", Data:{pcode:pcode}, type:"POST", DataType:"TEXT", Success:function(data) {varstr = ""; varHang = Data.split ("|"); for(vari=0;i) { varLie = Hang[i].split ("^"); STR+ = "<option value=" "+lie[0]+" > "+lie[1]+" </option> "; } $("#qu"). html (str); } }); } });chuli.php page:
<? PHP $pcode $_post ["Pcode"]; include (".. /dbda.class.php "); $db New Dbda (); $sql = "Select Areacode,areaname,parentareacode from chinastates where parentareacode= ' {$pcode} '" ; Echo $db->strquery ($sql);
May 20 Level Three linkage