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;
    }
    }
    }
 

你可能感兴趣的:(JavaScript,框架,function,prototype,asp.net,Parameters)