easyui-combobox與Select控件联动&&赋值筆記
双击select 移除某项ondblclick="this.removeChild(this.options[this.selectedIndex])"
不必在option 上定义 。代码如下:
<select style="width:400;height:300;" multiple="true"
ondblclick="this.removeChild(this.options[this.selectedIndex])">
<option value="aaa">aaa</option>
<option value="aaa">bbb</option>
<option value="aaa">ccc</option>
<option value="aaa">ddd</option>
<option value="aaa">eee</option>
</select>
//////////////////////////////////////////
//easyui-combobox联动
<input id="cc1" class="easyui-combobox" data-options="
value:'请选择...',
editable:false,
valueField: 'catCode',
textField: 'desc1',
url: '${pageContext.request.contextPath}/Coupon/Couponitemlist',
onSelect: function(rec){
var url = '${pageContext.request.contextPath}/Coupon/Couponitemlist2?cat='+rec.catCode;
$('#cc2').combobox('reload', url);
}">
<input id="cc2" class="easyui-combobox" data-options=" value:'请选择...',editable:false,valueField:'itemCode',textField:'desc1' ,onSelect: function(row){
var opts = $(this).combobox('options');
var desc1=row[opts.textField];
var code=row[opts.valueField];
var showstring='<option value='+code+'>'+desc1+'</option> '
<!-- $('#select1').append(showstring);-->
sll(desc1,showstring)
}">
<select ondblclick="this.removeChild(this.options[this.selectedIndex])" multiple id="select1" style="width:300px;height:200px;" >
<option value="测试移除">测试移除</option>
//////判断select1的内容,有重复的不添加,,在cc2中引用此函数select(desc1,showstring)
function sll(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);
}
}
}