zoukankan      html  css  js  c++  java
  • 动态向select multiple多选框添加元素

    动态向select multiple多选框添加元素

    <select ondblclick="this.removeChild(this.options[this.selectedIndex])" multiple id="select1" name="select1" style=" 300px; height: 200px;">
    <!-- <option value="测试移除">双击移除</option> -->
    </select>

    在js(<script></script>的)方法

    <script>

    function select(desc1,showstring){
    var sell=document.getElementById('select1');
    if(sell.length==0){

    $('#select1').append(showstring);/* alert("第一个"); */}
    else{
    /* alert("已有"+sell.length); */
    var qq="ture"
    for(var i=0;i<sell.length;i++){
    if(desc1==sell.options[i].text){
    qq="false";
    alert(desc1+"此选项已选择,不能重复选择");
    return;
    }
    }
    if( qq="ture"){
    $('#select1').append(showstring);
    }
    }
    }

    </script>

     修改页面的初始化select

    <select ondblclick="this.removeChild(this.options[this.selectedIndex])" multiple id="select1" name="select1" style=" 350px; height: 250px;">
    <!-- <option value="测试移除">双击移除</option> -->
    <c:if test="${!empty DCTP }">
    <c:forEach items="${DCTP}" var="DCTP">
    <c:forEach items="${Itemss}" var="Itemss">
    <c:if test="${DCTP.DOpen=='TRUE' && Itemss.itemCode==DCTP.detail}">
    <option value="${DCTP.DValue},${DCTP.type},${DCTP.DOpen},${DCTP.detail}">大類折扣:${DCTP.DValue}%,设为最高上限,${DCTP.detail}-${Itemss.desc1}</option>
    </c:if>
    <c:if test="${DCTP.DOpen=='FALSE' && Itemss.itemCode==DCTP.detail}">
    <option value="${DCTP.DValue},${DCTP.type},${DCTP.DOpen},${DCTP.detail}">大類折扣:${DCTP.DValue}%,${DCTP.detail}-${Itemss.desc1}</option>
    </c:if>
    </c:forEach>
    </c:forEach>
    </c:if>
    </select>

  • 相关阅读:
    CSS font-family 字体名称一览表
    jQuery动态追加移除CSS样式
    Java中super关键字的作用与用法
    I Have a Dream(我有一个梦想)
    再读《诫子书》
    世间谤我、欺我、辱我、笑我,为之奈何?
    英语句型:我除了音乐一无所能
    H5 iphoneX适配方案
    对象序列化成字符串,拼接在请求url后面
    React 60s倒计时
  • 原文地址:https://www.cnblogs.com/OP-RONG/p/4225950.html
Copyright © 2011-2022 走看看