日期:2014-05-16 浏览次数:20530 次
function Array2SelectList(srcObj,DefalutSelect,SourceArray,ParentValue) { var OptCount=0; var isSelected =false; SelectClear(srcObj);//Cleaer Options //srcObj.disabled = true; //alert(SourceArray.length ); for(var i = 0;i < SourceArray.length;i++){ if (SourceArray[i][2] == ParentValue || ParentValue ==null ){ //alert(SourceArray[i][2] + "-" + ParentValue ); OptCount++ //var opt=new Option(); //opt.value=SourceArray[i][0]; //opt.text =SourceArray[i][1]; srcObj.options[srcObj.length]=new Option(SourceArray[i][1],SourceArray[i][0]); if (SourceArray[i][0] == DefalutSelect){ isSelected = true; srcObj.options[srcObj.length-1].selected = true; } } } if (OptCount > 0){; srcObj.options[0].text=''; if (isSelected!=true){srcObj.options[0].selected = true;} //srcObj.disabled = false; } else{ srcObj.options[0].text=''; } } 该JS引用后续跟进。 function Array2SelectList2(srcObj,DefalutSelect,SourceArray) { var OptCount=0; var isSelected =false; SelectClear(srcObj);//Cleaer Options //srcObj.disabled = true; //alert(SourceArray.length ); for(var i = 0;i < SourceArray.length;i++){ OptCount++ //var opt=new Option(); //opt.value=SourceArray[i][0]; //opt.text =SourceArray[i][1]; srcObj.options[srcObj.length]=new Option(SourceArray[i][1],SourceArray[i][0]); if (SourceArray[i][0] == DefalutSelect){ isSelected = true; srcObj.options[srcObj.length-1].selected = true; } } if (OptCount > 0){; srcObj.options[0].text=''; if (isSelected!=true){srcObj.options[0].selected = true;} //srcObj.disabled = false; } else{ srcObj.options[0].text=''; } } function SelectClear(srcObj) {//Cleaer Select box Options if(srcObj.length>0){ for(var i= srcObj.length-1;i >= 0;i--) { srcObj.remove(i); } //var opt=new Option(); //opt.value=''; //opt.text =''; srcObj.options[srcObj.length]=new Option('',''); //srcObj.disabled = true; } else{ var opt=new Option(); opt.value=''; opt.text =''; srcObj.options[srcObj.length]=new Option('',''); } } function setOption(srcObj,intOptIndex,strOptValue,strOptText) {//Change select box's Option srcObj.options[intOptIndex].value=strOptValue; srcObj.options[intOptIndex].text=strOptText; } function GetArray(ParaSrcPath,ParaSource,ParaArrayName,ParaParent){ /*Great Array*/ ParaSource.src=ParaSrcPath + '&ArrayName='+ ParaArrayName +'&ParentID='+ ParaParent + "&rnd="+Math.random(); }