Query instance of the AJAX application of the second-level linkage of the background is the use of PHP to do

Source: Internet
Author: User

jquery instance of the Ajax application of the second-level linkage of the background is to do with PHP, the front desk through the Ajax way to achieve two-level linkage
database table Design Csj_trade

ID Int (one) auto_increment
Tname varchar (100)
Tradetype Int (one)

Where ID is the primary key auto-index, tname for the industry name, Tradetype as an identity, 0 o'clock, indicating that this data is a large class, not 0, but a number, this number represents the ID of its parent.
(1) Main Page

<script type= "Text/javascript" src= "/include/jquery/jquery-1.1.3.1.2881064151pack.js" ></script>
<select name= "Btrade" id= "Btrade" >
<option value= "-1" >--Industry-wide category--</option>
<?
$res 1=result ("select * from Csj_trade where tradetype=0");
while ($rs 1=mysql_fetch_array ($res 1)) {
?>
<option value= "<?= $rs 1[" id "]?>" >--<?= $rs 1["Tname"]?>--</option>
<?}? >
</select>
<span id= "Quote" >
<select name= "Strade" >
<option value= "-2" >--Industry small class--</option>
</select>
</span>
<script language= "JavaScript" >
$ ("#bTrade"). Change (function () {
$ ("#quote"). Load (".. /include/getstrade.php?id= "+$ (" #bTrade "). Val ());
});
</script>

(2) getstrade.php

<?
Require_once ("function.php");
Header ("Cache-control:no-cache");
$id =verify_id ($_get["id"]);
$res =result ("select * from Csj_trade where tradetype=". $id);
$rt = ' <select name= ' Strade "id=" S_trade ">";
while ($rs =mysql_fetch_array ($res)) {
$rt. = ' <option value= '. $rs ["id"]. ' " > '. $rs ["Tname"]. ' </option> ';
}
$rt. = ' </select> ';
Echo $rt;
?>

Query instance of the AJAX application of the second-level linkage of the background is the use of PHP to do

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.