easyui-combobox與Select控件联动&&赋值筆記

双击select 移除某项οndblclick="this.removeChild(this.options[this.selectedIndex])"
不必在option 上定义 。代码如下:

<select style="width:400;height:300;" multiple="true"
οndblclick="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 οndblclick="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);
}
}
}

转载于:https://www.cnblogs.com/OP-RONG/p/4193323.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值