首页 > 其他分享 >【Vegas原创】Ajax实现无刷新三联动

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

时间:2022-10-12 22:00:26浏览次数:48  
标签:exc value Ajax Vegas 联动 var document ds exczb

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" Selectinotallow="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代码

public class AjaxMethod
{
// private Connection conFlowER;
public AjaxMethod()
{
//
// TODO: 在此处添加构造函数逻辑

// conFlowER = new Connection(DatabaseType.Kernal);

// // string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F01'";
}

#region GetexcdeptList

public static DataSet GetexcdeptList()
{
string sql="select * from excdept";
return GetDataSet(sql);
}
#endregion

#region GetexcclassList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetexcclassList(int excdeptid)
{
string sql="select * from excclass where father="+excdeptid;
// string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F02'";
return GetDataSet(sql);
}
#endregion

#region GetexczbList
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public DataSet GetexczbList(int excclassid)
{
string sql="select * from exczb where father="+excclassid;
// string sql="select item_name,item_value from fm_code_list where form_kind='BQS.FORM.T601' and field_name='F03'";
return GetDataSet(sql);
}
#endregion

#region GetDataSet
public static DataSet GetDataSet(string sql)
{
string Cnotallow=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
SqlDataAdapter sda =new SqlDataAdapter(sql,ConnectionString);
DataSet ds=new DataSet();
sda.Fill(ds);
return ds;
}
#endregion


}
4.web.config
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>5.ajax.dll下载/Files/singlepine/Ajax.rar

标签:exc,value,Ajax,Vegas,联动,var,document,ds,exczb
From: https://blog.51cto.com/amadeus/5751671

相关文章

  • 【Vegas原创】导出Excel时,如何将数字格式转为文本格式?(07.12.13 Update)
    DataGrid:Asp.NetWebForm中DataGrid导出的时候,在ItemDataBound内if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem){e.Ite......
  • ajax 前后端交互
    前端<script>$('#id_edit').click(function(){$.ajax({url:'/set_password/',type:'post',data:{......
  • AJAX——简介
    AJAX 同步与异步 AJAX快速入门    ......
  • 尚硅谷-JavaWeb Day8 Filter、Json、Ajax
    1.Filter过滤器(JavaEE的规范,也是接口)作用:拦截请求、过滤响应;(应用于权限检查、日记操作、事务管理等等)①基本使用(通过判断session域中是否包含用户信......
  • JSP项目实训-Ajax聊天室
    存档资料成绩:课程设计报告书所属课程名称JSP项目实训题目Ajax聊天室分院专业班级学号学生姓名......
  • Servlet Servlet生命周期、java用swith取代多个if else、重载与重写、AJAX定义、应用
    大家可分享关于Java微服务相关知识,包括但不限于Java微服务开发经验、架构组成、技术交流、中间件等内容,我们鼓励springcloud架构为基础发散出击,从而达到技术积累的目的,快来......
  • 国家省市区四级联动
    后台模拟数据packagecom.ahut.action;importjava.util.ArrayList;importjava.util.HashMap;importjava.util.List;importjava.util.Map;importorg.springframework.we......
  • scrum看板工具如何与共享脑图联动
    ​思维导图是表达发散性思维的有效图形思维工具 ,它简单却又很有效同时又很高效,是一种实用性的思维工具。简单理解,看板就是一块能让人看得见的板子,核心作用就是将信息可......
  • 异步访问技术Ajax(XMLHttpRequest)
    目录​​AJAX​​​​XMLHttpRequest ​​​​Ajax向服务器发送请求​​​​Ajax接收服务器响应​​​​AJAX-onreadystatechange事件 ​​​​使用Callback函数​​......
  • ajax的原理
    、概念Ajax全称“AsynchronousJavaScriptandXml”异步JavaScript和XML),是一门创建交互式网页的开发技术,可以在网页不加载的情况下,实现局部更新,进行少量的数据交换。2、......