Three-level linkage between provincial and urban areas

Source: Internet
Author: User

In the daily Internet, we often encounter the provincial urban choice, here we explain the "provincial urban Three linkage"

First: Write div tags in HTML pages

<title> three-level linkage </title><script src= "jquery-2.0.0.min.js" ></script><script src= "Sanji.js" ></script>

  

Second: code that runs in JScript

1. First, the drop-down list fills the event

$ (document). Ready (function (e) {    $ ("#sanji"). HTML ("<select id= ' sheng ' ></select><select id= ' shi ' ></select><select id= ' qu ' ></select> ');//fill content//1. Fill province Fillsheng ();//2. Fill City Fillshi ();//3. Filling area fillqu ();

  

2. If the first level of the provincial selection changes, the second and third levels will also change

If the province is selected to change, go to fill the city and the district $ ("#sheng"). Change (function () {//Changed city Fillshi ();//Changed area Fillqu ();})

  

3. If the second level of the city selection changes, the third level will change

If the city chooses to change, go to fill the area $ ("#shi"). Change (function () {//Alter area fillqu ();})

  

4. The Province fill Fillsheng () function referenced above

Fill Province method function Fillsheng () {//Find parent code var pcode= "0001";//Call Ajax$.ajax ({async:false,url: "chuli.php", Data:{pcode: Pcode},type: "POST", DataType: "TEXT", success:function (data) {var str= ""; var hang = Data.split ("|"); for (Var i=0;i

  

5. The City fill Fillshi () function referenced above

Fill the city method function Fillshi () {//Find the parent codenamed Var pcode=$ ("#sheng"). Val ();//Call Ajax$.ajax ({async:false,url: "chuli.php", Data: {pcode:pcode},type: "POST", DataType: "TEXT", success:function (data) {var str= ""; var hang = Data.split ("|"); for (Var i=0;i

  

6. The area filled fillqu () function referenced above

The Fill Area method function Fillqu () {//finds the parent codenamed Var pcode=$ ("#shi"). Val ();//Call Ajax$.ajax ({async:false,url: "chuli.php", data:{ Pcode:pcode},type: "POST", DataType: "TEXT", success:function (data) {var str= ""; var hang = Data.split ("|"); for (Var i=0;i

  

Third: Ajax-run chuli.php code in JScript

<?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);

  

Three-level linkage between provincial and urban areas

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.