PHP language-three-level linkage

Source: Internet
Author: User

AreaCode AreaName Parentareacode

<script src= "Jquery-1.11.2.min.js" ></script>
<script src= "Sanji.js" ></script>
<body>

Sanji.js

Ajax synchronization, which means that when Ajax processes data, it must wait until processing is complete to execute the statement,

Ajax asynchronous, asynchronous refers to when the AJAX processing data, not wait until the processing, the following statement can be executed

Non-Ajax

Synchronization in the exchange of information, you must wait for the other party to confirm the receipt after the next message is sent

Asynchronously when exchanging information, just send it to each other, regardless of whether the other party has no reply

On the thread

Synchronization is equivalent to single-threaded processing of one request

Asynchronously equals multi-threaded processing of multiple requests simultaneously

$ (document). Ready (function(e) {//in Div three pull down early$ ("#sanji"). HTML ("<select id= ' sheng ' ></select><select id= ' shi ' ></select><select id= ' qu ' ></select> ');//Populating DataFillsheng ();//populating the province's dataFillshi ();//populating the city's dataFillqu ();//data for populated areas//ways to fill the provincefunctionFillsheng () {varCode = "0001";//Province's parent code//call Ajax to query the province's data$.ajax ({
Async:false,//asynchronous Ajax into synchronous Ajaxurl:
"Chuli.php", Data:{code:code},type:"POST", datatype:"TEXT", Success:function() {//split string, returns an array of rows
var hang = data.split ("|");

var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");

str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Put all the option in the Save Drop list
$ ("#sheng"). html (str);
}

});
}


function Fillshi ()
{
var code =$ ("#sheng"). Val (); City's parent code//Call Ajax query the province's data $.ajax ({

Async:false,url: "chuli.php", Data:{code:code},type: "POST", datatype: "TEXT", Success:function() {// Splits a string, returns an array of rows
var hang = data.split ("|");

var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");

str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Place all option in the City drop-down list
$ ("#shi"). html (str);
}

});

}


function Fillqu ()
{
var code =$ ("#shi"). Val (); The parent code of the zone//call the Ajax query for the province's data $.ajax ({

Async:false,url: "chuli.php", Data:{code:code},type: "POST", DataType: "TEXT", Success:function () {//split string, returns an array of rows
var hang = data.split ("|");

var str= "";
for (Var i=0;i
{
var lie = hang[i].split ("^");

str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>";
}
Place all option in the City drop-down list
$ ("#qu"). html (str);
}

});
}

When the selection of the province changes, to change the city and the district
$ ("#sheng"). Change (function () {
Fillshi ();
Fillqu ();
})
Change the area when the city's selection changes
$ ("#shi"). Change (function () {
Fillqu ();
})
});

chuli.php

<? PHP include "dbda.php"; $db New Dbda (); $pcode $_post ["Code"]; $sql = "Select Areacode,areaname from chinastates where Parentareacode = ' {$pcode} '"; Echo $db->strquery ($sql);

PHP language-three-level 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.