关于JS中option

来源:互联网 发布:出国翻译软件 编辑:程序博客网 时间:2024/06/10 09:01
function getAllPeople(date)
 {
 
  var selLen=document.myform.s2.options.length;
  for(var i=0;i<selLen;i++)
  {
   document.myform.s2.options.remove(0);//移除  }
  for(var i=0;i<date.length;i++)
  {
   document.myform.s2.options[document.myform.s2.options.length]=new Option(date[i].realName,date[i].id);//在尾部加option
  }
 }
<%-- 提交表单前判断 --%>
 function check()
 {
  if(document.getElementById("s3").options.length==0)
  {
   alert("请设置收件人");
   return false;
  }  
  return true;
  
 }
<%--  移动元素 --%>
  function moveOption(e1, e2){
try{
for(var i=0;i<e1.options.length;i++){
if(e1.options[i].selected){
var e = e1.options[i];
e2.options.add(new Option(e.text, e.value));
e1.remove(i);
}
}
}
catch(e){}
}
原创粉丝点击