免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1218 | 回复: 0
打印 上一主题 下一主题

ajax实现无刷屏级联下拉框 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-02 23:45 |只看该作者 |倒序浏览

1

      
2

            http_request=null;
3

            function doAJAX()
4


            

{
5

            if (window.XMLHttpRequest)
6


            

{
7

                http_request=new XMLHttpRequest();
8

            }
9

            else (window.ActiveXObject)
10


            

{
11

                http_request=new ActiveXObject("Microsoft.XMLHTTP");
12

            }
13

            http_request.onreadystatechange = GetDate;
14

              var S = document.Form1.select1.value;
15

              alert(S);
16

              var url='WebForm2.aspx?sABC='+escape(S);
17

              
18

           http_request.open('POST',url,true);
19

           var dataSet='sABC='+escape(S);
20

           http_request.send(null);
21

           }
22

            function GetDate()
23


            

{
24

              if (http_request.readyState==4)
25


            

{
26

                if(http_request.status==200)
27


               

{   
28

                    
29

                   var a= http_request.responseText.split(",");
30

                //清空原来的OPTIONS
31

                 var nL = document.Form1.select2.options.length;
32

                   while(nL>1)
33


                  

{
34

                        alert(document.Form1.select2.options.length);
35

                        document.Form1.select2.remove(document.Form1.select2.options.length-1);
36

                        nL = document.Form1.select2.options.length;
37

                   }
38

                   for(i=0;ia.length;i++)
39


                  

{
40

                   var opt=new Option();  
41

                   opt.value=a    ;
42

                   opt.text=a;
43

                   var sel1Object = document.Form1.select2;
44

                   sel1Object.add(opt);
45

                   }
46

                  
47

               }
48

               }
49

            }
50

            
51

      
52


1

        private void Page_Load(object sender, System.EventArgs e)
2


        

{
3

            string str;
4

            // 在此处放置用户代码以初始化页面
5

           string li= this.Request.Headers.ToString();
6

            this.Request.Headers.GetValues(0);
7

            if(Request.QueryString["sABC"]!=null)
8


            

{
9

                string aaa="";
10

                str = Request.QueryString["sABC"].ToString();
11

            
12

                ajaxDAL.Class1 test = new Class1();
13

                ArrayList al = test.Test(str);
14

                for(int i =0;ial.Count;i++)
15


               

{
16

                    aaa+= al.ToString()+",";
17

                }
18

                aaa = aaa.Remove(aaa.Length-1,1);
19

                Response.Write(aaa);
20

                Response.End();
21

            }
22

        }
23

24

25

        public ArrayList Test(string s)
26


        

{
27

            ArrayList al = new ArrayList();
28

            if(s=="美亚在线")
29


            

{
30

                al.Add("市场部");
31

                al.Add("开发部");
32

            }
33

            if(s=="美亚商旅")
34


            

{
35

                al.Add("商旅中心");
36

                al.Add("物流部");
37

            }
38

            return al;
39

        }
40



本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10945/showart_332777.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP