select二级联动

本文介绍了一个使用Ext.Ajax实现的异步加载二级部门下拉菜单的JavaScript函数。当用户选择一级部门后,该函数会清空二级部门下拉选单并请求对应的二级部门列表,然后填充到下拉选单中。文章详细展示了如何通过AJAX进行异步请求及响应处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

f

function getAgent(firstA){
    var i,j;
//清空 二级部门 下拉选单,仅留下默认的“请选择”
    document.all.DropDownLists2.length = 1;
//异步请求firstA下的二级菜单
    if(firstA != "-1")//当选 的不是“----请选择-------”
    {
         Ext.Ajax.request({
             url:'GetSecondGrade?firstDepartmentID='+firstA,
             method:'POST',
             success:function(response,options){
                      if(response.responseText != "")
                      {
                             //填充二级部门 下拉列表
                             tmpArray = response.responseText.split(";");
                             for(j=0;j<tmpArray.length;j++)
                             {
                                secondArray = tmArray[j].split(":");
                                document.all.DropDownLists2.options[document.all.DropDownList2.length] =  new Option(secondArray[1],secondArray[0]);
                             }
                             document.all.DropDownList2.length = document.all.DropDownList2.length-1;
                      }
             },
            failure:function(response,options)
            {
                Ext.MessageBox.alert('失败','请求超时或网络故障:'+response.status);
            },
            scope:this
         }); 
     }
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值