小菜毛毛技术分享

与大家共同成长

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  164 Posts :: 141 Stories :: 94 Comments :: 0 Trackbacks
HTML代码:
<div align="left">
 <div style="float:left">
 <select name="select1" size="20" id="allTimeLimitmr" multiple="multiple" style="height: auto;width: auto;">
     <option value="null" disabled="disabled" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key="setting.timelimitmr"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>\
     <c:if test="${tlmr!=null}">
   <c:forEach items="${tlmr}" var="TimeLimitmr" >
     <option value='${TimeLimitmr.match_rule_id}' >${TimeLimitmr.match_rule_name}</option>
   </c:forEach>
  </c:if>
      </select>
  </div>
  <div style="float:left; margin-top:100px;margin-left: 2px">
   <input name="button" type="button" onclick="addTache();" value="<fmt:message key="button.add" />" /><br>
   <input name="button3" type="button" onclick="removeTache();" value="<fmt:message key="button.delete"/>" /><br>
      </div>
   <div style="float:left">
       <select name="select" size="20" id="select" multiple="multiple" style="height: auto;width: auto;">
       <option value="null" disabled="disabled" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key="setting.timelimitmr.have"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>       
  <c:if test="${tlmr!=null}">
   <c:forEach items="${isselect}" var="istimeLimitmr" >
     <option value='${istimeLimitmr.match_rule_id}' >${istimeLimitmr.match_rule_name}</option>
   </c:forEach>
  </c:if>
      </select>
   </div>
</div>
JAVASCRIPT代码:
function addTache(){
  var len= document.getElementById("allTimeLimitmr").length;
  for(var i=0;i<len;i++){
   var option = document.getElementById("allTimeLimitmr").options[i];
   if(option.selected == true && option.index!=0){
    var newoption = document.createElement('option');  
                newoption.value = option.value;
    newoption.text  = option.text;
  
    document.getElementById("select").add(newoption);
   }
  }
 }
 function removeTache(){
  var len= document.getElementById("select").length;
  for(var i=0;i<len;i++){
      var option = document.getElementById("select").options[i];
   if(option.selected == true && option.index!=0 ){
    var tempoption = document.getElementById("select").options[i];
    document.getElementById("select").options[i].removeNode(true);
   }
  }
 }
 
 function submitTache(){
  
  var len = document.getElementById("select").length;
  var formobject = document.getElementById("alarmRuleForm");
  for(var i=0;i<len;i++){
   var option = document.getElementById("select").options[i];
   if(option.index!=0 ){
       var actiontype= "0";
    var input = document.createElement("<input type='hidden' name='timelimitmr' />");
    input.value=option.value;
    formobject.insertAdjacentElement("beforeEnd",input);
   }
  }
  formobject.submit();
 }
</script>
posted on 2009-05-31 09:14 小菜毛毛 阅读(2506) 评论(1)  编辑  收藏 所属分类: HTML+div+css实践

Feedback

# re: select multiple 2012-09-28 13:55 wq
wewe  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: