Second-level linkage

Source: Internet
Author: User

City Controller aspects

Provincial area
Public Function one () {
$data =db::table (' area ')->where ("Parent_id=0")->select ();
$AA = $data [0][' id ']+100;
$shi _ji=db::table ("area")->where ("Parent_id= ' $aa '")->select ();
$arr =[' data ' and $data, ' Shi ' and $shi _ji];
return View ("Show", [' arr ' = $arr]);
}
City-level areas
Public Function () {
$id =request::instance ()->param ("id");
$b =db::table (' area ')->where ("Parent_id= ' $id '")->select ();
return View ("Show1", [' arr ' = $b]);
}
Province
Public Function three () {
$id =request::instance ()->param ("id");
$b =db::table (' area ')->where ("Parent_id= ' $id '")->select ();
return View ("Show2", [' arr ' = $b]);
}

//html page Show page shows provincial city
<table>
<tr>
<td> Provincial:</td>
<td>
<select name= "" id= "" class= "one" >
<option value= "Please select" > Please select </option>
{volist name= "arr.data" id= "V"}
<option value= "{$v. ID}" >{$v .name}</option>
{/volist}
</select>
</td>
<td> City-level:</td>
<td>
<select name= "" id= "" class= "" >
<option value= "" ></option>
</select>
</td>
<td> County/District:</td>
<td>
<select name= "" id= "" class= "three" >

<option value= "" ></option>

</select>
</td>

</tr>
</table>

//js Call Show1 show2 page

$ (document). On ("Change", ". One", function () {
var one=$ (this). Val ();
$.get (
"{: url (' login/two ')}?id=" +one,
function (data) {
$ ("."). HTML (data);
}
)
})

//Urban
$ (document). On ("Change", ".", Function () {
var two=$ (this). Val ();
$.get (
"{: url (' login/three ')}?id=" +two,
function (data) {
$ (". three"). HTML (data);
}
)
})




Show1 Show Level Two cities
<select name= "" id= "" class= "one" >
<option value= "" > Please select </option>
{volist name= "arr" id= "V"}
<option value= "{$v. ID}" >{$v .name}</option>
{/volist}
</select>


Show2 Show Level Three cities
<select name= "" id= "" class= "one" >
<option value= "" > Please select </option>
{volist name= "arr" id= "V"}
<option value= "{$v. ID}" >{$v .name}</option>
{/volist}
</select>



Second-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.