Asp.Net+ProtoType框架 绑定DropDownList二级联动 JavaScript函数

// JScript
function CompanyShowTel(companyid,divshow){//Read CompanyShow
//  alert('123');
//  alert(divshow);
  new Ajax.Updater({success:divshow},
  'AjaxFile/CompanyShowTel.aspx?companyid='+companyid+''+'&no-cache='+Math.random(),
  {
  method:'get',parameters:'',onFailure:reportError,evalScripts: true
  }  
  );
//  alert('fff');
  }
  function reportError(request){//Error
//  alert(request);
  alert('Sorry,There was an error');
  }
  
  function CompanyModelShow(companyid,divshow){//Read Mode
//  alert('123');
//  alert(divshow);
  new Ajax.Updater({success:divshow},
  'AjaxFile/CompanyModelShow.aspx?companyid='+companyid+''+'&no-cache='+Math.random(),
  {
  method:'get',parameters:'',onFailure:reportError,evalScripts: true
  }  
  );
//  alert('fff');
  }

function CompanyEmployeeList(companyid,divshow){
    var myAjax = new Ajax.Request('../AjaxFile/Admin/AjaxCompanyEmployee.aspx',{method:'get',parameters:'companyid='+companyid+''+'&no-cache='+Math.random(),onComplete:CompanyEmployeeListShow});   
}

function CompanyEmployeeListShow(Result){
//alert(Result.responseText);
var result=Result.responseText;
//alert(result);
//清空DropDownList
DropDownListClear('ddlClassId');
if(result==null){
return false;
}
//循环添加DropDownList
DropDownListAdd('ddlClassId',result);
}

function DaquCompanyList(companyid,divshow){
    var myAjax = new Ajax.Request('../AjaxFile/Admin/AjaxDaquCompany.aspx',{method:'get',parameters:'companyid='+companyid+''+'&no-cache='+Math.random(),onComplete:DaquCompanyListShow});   
}

function DaquCompanyListShow(Result){
//alert(Result.responseText);
var result=Result.responseText;
//alert(result);
//清空DropDownList
DropDownListClear('ddlCompanyId');
if(result==null){
return false;
}
//循环添加DropDownList
DropDownListAdd('ddlCompanyId',result);
}

          function DropDownListClear(ddlist){//清空DropDownList
          var countnum=document.getElementById(ddlist).options.length;
          for(var i=0;i<=countnum;i++){//清空DropDownList
          document.getElementById(ddlist).remove(countnum-i);
          }
          }
         
          function DropDownListAdd(ddlist,result){//循环添加DropDownList
          var array=result.split("|");
for(var i=0;i<array.length;i++){
var optionarray=array[i].split(",");
var newoption=document.createElement("option");
newoption.text=optionarray[1];
newoption.value=optionarray[0];
document.getElementById(ddlist).options.add(newoption);
}
//var newoption2=document.createElement("option");
//newoption2.text="请选择所属员工";
//newoption2.value="";
//document.getElementById(ddlist).options.add(newoption2);
//alert(document.getElementById(ddlist).options.length);
//alert(document.getElementById(ddlist).options.length-1);
document.getElementById(ddlist).selectedIndex=eval(document.getElementById(ddlist).options.length)-1;
          }
         
    function DropDownListSelected(ddlist,value){
    //alert('value='+value);
    var countnum=document.getElementById(ddlist).options.length;   
//    alert('value2='+value);
    for(var i=0;i<countnum;i++){
    if(document.getElementById(ddlist).options[i].value==value){
//    alert(document.getElementById(ddlist).options[i].value);
    document.getElementById(ddlist).options[i].selected=true;
//    alert('Ok');
    return false;
    }
    }
    }
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值