May 20 Level Three linkage

Source: Internet
Author: User

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

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.