動態向select multiple多選框添加元素app
<select ondblclick="this.removeChild(this.options[this.selectedIndex])" multiple id="select1" name="select1" style="width: 300px; height: 200px;">
<!-- <option value="測試移除">雙擊移除</option> -->
</select>測試
在js(<script></script>的)方法this
<script>ip
function select(desc1,showstring){
var sell=document.getElementById('select1');
if(sell.length==0){rem
$('#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);
}
}
}get
</script>string
修改頁面的初始化selectit
<select ondblclick="this.removeChild(this.options[this.selectedIndex])" multiple id="select1" name="select1" style="width: 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>io