【Vegas原创】Ajax实现无刷新三联动

2年前 (2022) 程序员胖胖胖虎阿
307 0 0

1.html代码:
     

 <SCRIPT language="javascript">               
 
//部别------------------------------
            function excclassResult() 
            { 
                
var excclass=document.getElementById("exc_dept");
                AjaxMethod.GetexcclassList(excclass.value,get_excclass_Result_CallBack);
            }
            
            
function get_excclass_Result_CallBack(response)
            {
                
if (response.value != null)
                {                    
                    
                    
//debugger;
                    document.all("exc_class").length=0;                
                
var ds = response.value;
                
//alert (ds.Tables[0].Rows[0].escclass);
                    if(ds != null && typeof(ds) == "object" && ds.Tables != null)
                    {                    
                        
for(var i=0; i<ds.Tables[0].Rows.length; i++)
                    {
                        
var name=ds.Tables[0].Rows[i].escclass;
                      
var id=ds.Tables[0].Rows[i].escclassid;
                      document.all(
"exc_class").options.add(new Option(name,id));
                    }
                    }
                } 
                             
                
return 
            }
            
//站别----------------------------------------
            function exczbResult() 
            { 
                
                
//var a=document.all("exc_class").options[document.all("exc_class").SelectedIndex].Value;
                //alert (a);
                var exczb=document.getElementById("exc_class");
                
//alert(exczb.value);
                //var exczb=document.all("exc_dept");
               
                
                
//alert (exczb.value);
                AjaxMethod.GetexczbList(exczb.value,get_exczb_Result_CallBack);
            }
            
function get_exczb_Result_CallBack(response)
            {
               
//alert (response.value)
                if (response.value != null)
                {                    
                    
                    document.all(
"exc_zb").length=0;                
                
var ds = response.value;
                    
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
                    {                    
                        
for(var i=0; i<ds.Tables[0].Rows.length; i++)
                    {
                      
var name=ds.Tables[0].Rows[i].exczb;
                      
var id=ds.Tables[0].Rows[i].exczbID;
                      document.all(
"exc_zb").options.add(new Option(name,id));
                    }                
                    }
                }
                
return
            }
            
function getData()
            {
                
var excdept=document.getElementById("exc_dept");
                
var pindex = excdept.selectedIndex;
                
var pValue = excdept.options[pindex].value;
                
var pText  = excdept.options[pindex].text;
                
                
var excclass=document.getElementById("exc_class");
                
var cindex = excclass.selectedIndex;
                
var cValue = excclass.options[cindex].value;
                
var cText  = excclass.options[cindex].text;
                
                
var exczb=document.getElementById("exc_zb");
                
var aindex = exczb.selectedIndex;
                
var aValue = exczb.options[aindex].value;
                
var aText  = exczb.options[aindex].text;            
            }
</SCRIPT>

【Vegas原创】Ajax实现无刷新三联动<tr>
【Vegas原创】Ajax实现无刷新三联动
<td>发现厂别</td>
【Vegas原创】Ajax实现无刷新三联动
<td>
【Vegas原创】Ajax实现无刷新三联动
<asp:dropdownlist id="Dropdownlist1" runat="server"></asp:dropdownlist>
【Vegas原创】Ajax实现无刷新三联动
</td>
【Vegas原创】Ajax实现无刷新三联动
<td>事业部别</td>
【Vegas原创】Ajax实现无刷新三联动
<td>
【Vegas原创】Ajax实现无刷新三联动
<asp:dropdownlist id="Dropdownlist2" runat="server"></asp:dropdownlist>
【Vegas原创】Ajax实现无刷新三联动
</td>
【Vegas原创】Ajax实现无刷新三联动
</tr>
【Vegas原创】Ajax实现无刷新三联动
<tr>
【Vegas原创】Ajax实现无刷新三联动
<td>站别名称</td>
【Vegas原创】Ajax实现无刷新三联动
<td  colSpan="3" >
【Vegas原创】Ajax实现无刷新三联动
<tr>
【Vegas原创】Ajax实现无刷新三联动
<td width="137" rowSpan="3">
【Vegas原创】Ajax实现无刷新三联动
<asp:listbox id="Listbox1" runat="server" SelectionMode="Multiple"></asp:listbox>
【Vegas原创】Ajax实现无刷新三联动
</td>

2.cs代码

    Ajax.Utility.RegisterTypeForAjax(typeof(AjaxMethod));
            
if(!Page.IsPostBack)
            {
                
this.exc_dept.DataSource=AjaxMethod.GetexcdeptList();
                
this.exc_dept.DataTextField="excdept";
                
this.exc_dept.DataValueField="excdeptid";
                
this.exc_dept.DataBind();
                
this.exc_dept.Attributes.Add("onclick","excclassResult();");
                
this.exc_class.Attributes.Add("onclick","exczbResult();");
            }

         3.Ajax代码

【Vegas原创】Ajax实现无刷新三联动


4.web.config

<httpHandlers>
            
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
    
</httpHandlers>


5.ajax.dll下载/Files/singlepine/Ajax.rar

版权声明:程序员胖胖胖虎阿 发表于 2022年9月18日 下午8:40。
转载请注明:【Vegas原创】Ajax实现无刷新三联动 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...