博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

AjaxPro实现三级联动

Posted on 2008-02-18 01:39  周末  阅读(337)  评论(0)    收藏  举报
 1<%@ Page Language="C#" AutoEventWireup="true"  EnableEventValidation="false"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 3<!--更新日期2007-5-12-->
 4<html xmlns="http://www.w3.org/1999/xhtml" >
 5<head runat="server">
 6    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
 7    <title>AjaxPro实现无刷新三级联动</title>
 8    <script language="javascript" type="text/javascript">
 9      <!--
10       // ACLOUD 常用JS函数
11       function getBid(s){
12    return document.getElementById(s);
13  }

14  function getBmc(s){
15    return document.getElementByName(s);
16  }

17  
18       //显示分类列表
19    function showNext(sid,obj)
20        
21          if(sid==null || sid=="" || sid.length<1)return;
22          var slt =getBid(obj);
23       var v = _Default.getNextClass(sid).value; // 类的名称
24       //alert(v);
25       //return;
26       if (v != null){      
27    if(v != null && typeof(v) == "object" && v.Tables != null)
28     {  
29         slt.length = 0;
30         slt.options.length = 0;
31         slt.options.add(new Option("请选择",0));
32         //加了个“请选择”主要为了触发onchange事件
33         if(obj=="ddl2"){
34         getBid("ddl3").options.length=0;
35         getBid("ddl3").options.add(new Option("请选择",0));
36         }
   
37      for(var i=0; i<v.Tables[0].Rows.length; i++)
38        {
39         var txt = v.Tables[0].Rows[i].txt; //这个地方需要注意区分大小写
40          var vol = v.Tables[0].Rows[i].vol; //跟dataset表的列名称要一致
41          slt.options.add(new Option(txt,vol));
42        }

43     }

44     }
 
45     return;
46         }

47         
48         //JS方法取值
49         
50        -->
51</script>
52</head>
53
54<body>
55    <form id="form1" runat="server">
56    <div>
57      <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
58        <tr>
59          <td width="99" height="35">&nbsp;</td>
60          <td style="width: 401px">
61              省份<asp:DropDownList ID="ddl1" runat="server">
62              </asp:DropDownList>
63              城市<asp:DropDownList ID="ddl2" runat="server">
64              </asp:DropDownList>
65              区域<asp:DropDownList ID="ddl3" runat="server">
66              </asp:DropDownList></td>
67        </tr>
68        <tr>
69          <td height="30">&nbsp;</td>
70          <td style="width: 401px">&nbsp;</td>
71        </tr>
72        <tr>
73          <td height="50">&nbsp;</td>
74          <td style="width: 401px">&nbsp;</td>
75        </tr>
76      </table>
77    
78    </div>
79    </form>
80</body>
81</html>
82
83Web.config文件代码:
84
85<configuration>
86 <appSettings>
87  <add key="dbpath" value="~/App_Data/class.mdb"/>
88    <add key="website" value="blog.etao8.cn"/>
89 </appSettings>
90 <connectionStrings/>
91 <system.web>
92    <!--for Ajaxnet-->
93    <httpHandlers>
94      <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
95    </httpHandlers>
96
97