jquery ajax 读取联动菜单 select菜单
jquery ajax 读取联动菜单 select菜单
JavaScript Code
- <script type="text/javascript">
- $(document).ready(function()
- {
- $(".country").change(function()
- {
- var id=$(this).val();
- var dataString = 'id='+ id;
- $.ajax
- ({
- type: "POST",
- url: "ajax.php",
- data: dataString,
- cache: false,
- success: function(html)
- {
- $(".city").html(html);
- }
- });
- });
- });
- </script>
XML/HTML Code
- <div style="margin:20px">
- <label>大类:</label> <select name="country" class="country">
- <option selected="selected">--Select--</option>
- <?php
- include('../../conn.php');
- $sql=mysql_query("select * from bigclass");
- while($row=mysql_fetch_array($sql))
- {
- $id=$row['bigclassid'];
- $data=$row['bigclassname'];
- echo '<option value="'.$id.'">'.$data.'</option>';
- } ?>
- </select> <br/><br/>
- <label>小类 :</label>
- <select name="city" class="city">
- <option selected="selected">--Select--</option>
- </select>
- </div>
ajax.php
PHP Code
- <?php
- include('conn.php');
- if($_POST['id'])
- {
- $id=$_POST['id'];
- $sql=mysql_query("select * from smallclass where bigclassid='$id'");
- while($row=mysql_fetch_array($sql))
- {
- $id=$row['smallclassid'];
- $data=$row['smallclassname'];
- echo '<option value="'.$id.'">'.$data.'</option>';
- }
- }
- ?>
相关推荐
周公周金桥 2020-09-06
大象从不倒下 2020-07-31
AlisaClass 2020-07-19
MaureenChen 2020-04-21
xingguanghai 2020-03-13
teresalxm 2020-02-18
木四小哥 2013-05-14
SoShellon 2013-06-01
Simagle 2013-05-31
羽化大刀Chrome 2013-05-31
waterv 2020-01-08
LutosX 2013-07-29
vanturman 2013-06-27
wutongyuq 2013-04-12
luoqu 2013-04-10
today0 2020-09-22
89520292 2020-09-18
bigname 2020-08-25