【Vegas原创】Ajax实现无刷新三联动
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>
<tr>
<td>发现厂别</td>
<td>
<asp:dropdownlist id="Dropdownlist1" runat="server"></asp:dropdownlist>
</td>
<td>事业部别</td>
<td>
<asp:dropdownlist id="Dropdownlist2" runat="server"></asp:dropdownlist>
</td>
</tr>
<tr>
<td>站别名称</td>
<td colSpan="3" >
<tr>
<td width="137" rowSpan="3">
<asp:listbox id="Listbox1" runat="server" SelectionMode="Multiple"></asp:listbox>
</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代码
4.web.config
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
5.ajax.dll下载/Files/singlepine/Ajax.rar
喜欢请赞赏一下啦^_^