zoukankan      html  css  js  c++  java
  • ajax/应用1

       //init_xmlhttp函数会根据不同的浏览器初始化xmlhttp对象 
             function init_xmlhttp()
             
    {
                   
    var A=null
                   
    try 
                   

                        A
    =new ActiveXObject("Msxml2.XMLHTTP"); //IE 
                   }
     
                   
    catch(e) 
                   

                       
    try 
                       

                             A
    =new ActiveXObject("Microsoft.XMLHTTP"); //非IE
                       }
     
                       
    catch(oc) 
                       

                             A
    =null 
                       }
     
                   }

                   
                   
    if ( !&& typeof XMLHttpRequest != "undefined" ) 
                   

                        A
    =new XMLHttpRequest() 
                   }
     
                  
    return A 
             }


          
            
    function Go(obj) 
            

                
                  
    var var1 = document.form1.ddl_1[document.form1.ddl_1.selectedIndex].value;
                  
    if((var1 == "7")||(var1 == "5")) //5核销人 7 支付方式
                  {
                        
    //得到选择框的下拉列表的value 
                        var svalue = obj.value;   
    //                    alert(svalue);return false;
                        //定义要处理数据的页面 
                        var weburl = "select_data_ysfhxcx.aspx?list_item_value="+svalue;    
                        
    //初始化个xmlhttp对象 
                        var xmlhttp = init_xmlhttp(); 
                        
                        
    //去weburl获取数据,第一个参数最好为get,第三个参数最好为true 
                        xmlhttp.open("get",weburl,true); 
    //                    alert("a"); return false;//执行了
                        xmlhttp.onreadystatechange=function() 
                        
    {
    //                        alert(xmlhttp.readyState); return false;//这时接到的值为1,不知是什么意思,可能表示开始执行,在select_data_ysdzd.aspx中就能断到断点
                            if(xmlhttp.readyState == 4)//4代表成功返回数据 
                            {
                                
    var result = xmlhttp.responseText;//得到服务器返回的数据
                                document.getElementById("txt_of_pnl1").style.display = "none";
                                document.getElementById(
    "ddl_of_pnl1").style.display="";
                                document.getElementById(
    "ddl_of_pnl1").length = 0;                                           
                                document.getElementById(
    "ddl_of_pnl1").options.add(new Option(" "," ")); 
                                
    if(result != "")//如果返回的数据不是空 
                                {
    //                               alert(result);return false;
                                     var allArray = result.split(",");
                                     
    //循环这个数组,注意是从1开始,因为收到的字符串第一个字符是,号,所以分割后第一个数组为空 
                                     for(var i=1;i<allArray.length;i++
                                     
    {
                                        
    var thisArray = allArray[i].split("|");
                                        document.getElementById(
    "ddl_of_pnl1").options.add(new Option(thisArray[0].toString(),thisArray[1].toString())); 
                                     }

                                }

                                
    else
                                
    {
                                    document.getElementById(
    "ddl_of_pnl1").length = 0
                                }

                            }

                            
                        }

                         xmlhttp.send(
    null); //没有这句,根本进不到select_data_ysdzd.aspx页面!!!!!     
                  }
    //if((var1 == "7")||(var1 == "5"))   End
                  else
                  
    {
                       document.getElementById(
    "txt_of_pnl1").style.display = "";
                       
                       document.getElementById(
    "ddl_of_pnl1").style.display = "none";
                  }

            }
    CS:
      ddl_1.Attributes.Add("onchange""Go(this)");//最左边的按钮"各种检索条件"
            this.ddl_of_pnl1.Attributes.Add("onchange""javascript:document.form1.hid_ddl_right.value=this.value;");//右边panel中的DDL


    HTML:
     <td>
            
    <asp:DropDownList ID="ddl_1" runat="server" Width="140px">
                
    <asp:ListItem Text="" Value="0"></asp:ListItem>
                
    <asp:ListItem Text="编号" Value="1"></asp:ListItem>            
                
    <asp:ListItem Text="单号" Value="2"></asp:ListItem>            
                
    <asp:ListItem Text="凭证号" Value="3"></asp:ListItem>
                
    <asp:ListItem Text="支票号" Value="4"></asp:ListItem>            
                
    <asp:ListItem Text="核销人" Value="5"></asp:ListItem>
                
    <asp:ListItem Text="涉帐单位" Value="6"></asp:ListItem>
                
    <asp:ListItem Text="支付方式" Value="7"></asp:ListItem>
            
    </asp:DropDownList>
        
    </td>
        
    <td>        
            
    <asp:Panel ID="pnl1" runat="server" Width="100px" >
                
    <asp:TextBox ID="txt_of_pnl1" runat="server" Width="140px" CssClass="input_text"></asp:TextBox>
                
    <asp:DropDownList ID="ddl_of_pnl1" style="display:none;" runat="server"   Width="140px">
                                    
    </asp:DropDownList>
            
    </asp:Panel>
        
    </td>
  • 相关阅读:
    创建聚合工程的子工程时 webapp文件变灰色问题
    redis的各大数据类型
    webpack整合Vue
    springboot的介绍
    C# 4.0 新对象ExpandoObject
    Customer Data Import for AX2012
    【转】Javascript中最常用的55个经典技巧
    Sample for Integration G2 To MSCRM
    Connector for Microsoft Dynamics 安装配置(一)
    第二节 HTML5通用接口介绍
  • 原文地址:https://www.cnblogs.com/simhare/p/901797.html
Copyright © 2011-2022 走看看