asp.net基于jquery的ajax二级联动

来源:互联网 发布:mac双色修容粉多少钱 编辑:程序博客网 时间:2024/04/28 12:38

刚刚修改的  以前是很早之前写的了

 

有很多不足之处

 

现在写最新的吧(现在的代码高亮怎么没有html的了?)

 

那html 直接贴代码了 哎

 

 

 

index.aspx

 

 

<script src="../ADMIN/js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {

//预先加载第一个select,加载品牌,看好加载的的页面BrandHandler.ashx

        $.post('BrandHandler.ashx', {}, function(data) { $("#carbrand").html(data) }, 'html');

//当选择品牌的时候加载二级车系,构成联动
        $("#carbrand").change(function() {
        $.post('TypeHandler.ashx', { cartype: $(this).val() }, function(data) { $("#cartype").empty().html(data) }, 'html');
        });
    });
</script>
<table  width="950" height="35" border="0" cellpadding="0" cellspacing="0" class="left_tb">
  <tr>
    <td width="70" align="right" background="../IMAGES/b_4.gif"><img src="../IMAGES/serch_so.gif" width="59" height="17" /></td>
    <td width="100" background="../IMAGES/b_4.gif">
        <select id="carbrand" name="carbrand" >
            <option value="-1">--选择品牌--</option>
        </select>
        </td>
    <td width="105" background="../IMAGES/b_4.gif">
        <select id="cartype" name="cartype" >
            <option value="-1">--选择车系--</option>
        </select>
        </td>
    <td background="../IMAGES/b_4.gif" style="width:80px">
        &nbsp;
       <a href="###" id="search_type"><img  src="../IMAGES/serch.gif" alt="搜索" style="border:0px"/></a>
       </td>
    <td width="120" background="../IMAGES/b_4.gif">
        <input id="TextKeys" type="text"   />
        </td>
    <td width="100" align="left" background="../IMAGES/b_4.gif">
   <a href="###" id="search_news"> <img alt="新闻资讯" src="../IMAGES/serch.gif"  style="border:0"/></a>
    </td>
  </tr>
</table>

 

 

 

 

 

BrandHandler.ashx

 

 

 

 

TypeHandler.ashx

 

 

 

 

 

 

OK    2009-12-04  08:45:29