1, query database in the form of three-level linkage show

Source: Internet
Author: User

1<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>5<title> Untitled Document </title>6 7<script src= "Jquery-1.11.2.min.js" ></script>8<script src= "Sj.js" ></script>9Ten  One<body> A -  -<div id= "Sanji" ></div> the</body> - -  - //I wrote the JS package +  -$ (document). Ready (function(e) { +      A     //Create three drop-down in div at$ ("#sanji"). HTML ("<select id= ' sheng ' ></select><select id= ' shi ' ></select><select id= ' qu ' ></select> '); -      -     //Populating Data -Fillsheng ();//populating the province's data -Fillshi ();//populating the city's data -Fillqu ();//data for populated areas in  - //How to fill the province to     functionFillsheng () +     { -         varCode = "0001";//Province's parent code the //Call Ajax to query the province's data *$.Ajax ({ $             Panax NotoginsengAsyncfalse,//become synchronous Ajax -URL: "cls.php", theData:{code:code}, +Type: "POST", ADataType: "TEXT", theSuccessfunction(data) { +                     //splits a string, returns an array of rows -                     varHang = data.Split("|"); $                     varstr = ""; $                      for(vari=0;i) -                     { -                         varLie = Hang[i].Split("^"); the                          -                         //var a=lie[0].trim ();Wuyistr+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>"; the                     } -                     //put all the option in the save-pull. Wu$ ("#sheng").html (str); -                 } About              $             }); -     } -      -     //methods of filling the city A     functionFillshi () +     { the         varCode = $ ("#sheng"). Val ();//City's parent code -  $ //Call Ajax to query the province's data the$.Ajax ({ the              theAsyncfalse,//become synchronous Ajax theURL: "cls.php", -Data:{code:code}, inType: "POST", theDataType: "TEXT", theSuccessfunction(data) { About          the                     //splits a string, returns an array of rows the                     varHang = data.Split("|"); the                     varstr = ""; +                      for(vari=0;i) -                     { the                         varLie = Hang[i].Split("^");Bayi                         //var a = Lie[0].trim (); thestr+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>"; the                     } -                     //put all the option in the save-pull. -$ ("#shi").html (str); the                 } the              the             }); the     } -      the     //methods for populating the area the     functionFillqu () the     {94         varCode = $ ("#shi"). Val ();//The parent code of the zone the //Call Ajax to query the province's data the$.Ajax ({ the             98Asyncfalse,//become synchronous Ajax AboutURL: "cls.php", -Data:{code:code},101Type: "POST",102DataType: "TEXT",103Successfunction(data) {104                     //splits a string, returns an array of rows the                     varHang = data.Split("|");106                     varstr = "";107                      for(vari=0;i)108                     {109                         varLie = Hang[i].Split("^"); the                         111str+= "<option value= '" +lie[0]+ ">" +lie[1]+ "</option>"; the                     }113                     //put all the option in the save-pull. the$ ("#qu").html (str); the                 } the             117             });118     }119      -     //when the selection of the province changes, to change the city and the District121$ ("#sheng"). Change (function(){122 Fillshi ();123 fillqu ();124         }) the         126     //when the city's selection changes, to change the district127$ ("#shi"). Change (function(){ - fillqu ();129         }) the });131  the //Working with pages133<?PHP134 include("haoyou.php");135 $db=Newhaoyou ();136 137 $pcode=$_post["Code"];138 $sql= "Select Areacode,areaname from chinastates where parentareacode= ' {$pcode}‘";139  $ Echo $db->strquery ($sql);

1, query database in the form of three-level linkage show

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.