页面写法
<div class="" id="returnReasons" data-options="region:'south'" style="width:100%;height:100px"> <table cellspacing='0' class="reasonTableForm"> <td>缺失:</td> <td> <select id="materialMissing" name="materialMissing" data-options="editable:true,width:200" style="width:100%; height:50%"></select> <div id="mmid"> <#if materialMissing??> <#list materialMissing as item> <input type="checkbox" name="materialMissing" value="${item.dictId!}"><span>${item.dictData!}</span> <br/> </#list> </#if> </div> </td> <tr> <td>错误:</td> <td> <select id="materialError" name="materialError" data-options="editable:true,width:200" style="width:100%; height:50%"></select> <div id="meid"> <#if materialError??> <#list materialError as item> <input name="materialError" type="checkbox" value="${item.dictId!}"><span>${item .dictData!}</span> <br/> </#list> </#if> </td> </tr> </table> </div>
js写法
$(function() { $('#materialMissing').combo({ required : false, editable : true, multiple : true }); $('#mmid').appendTo($('#materialMissing').combo('panel')); $("#mmid input") .click( function() { var _value = ""; var _text = ""; $("[name=materialMissing]:input:checked").each(function() { if(_value.length>0){ _value +="," + $(this).val(); }else{ _value +=$(this).val(); } if(_text.length>0){ _text += "," +$(this).next("span").text(); }else{ _text += $(this).next("span").text(); } }); //设置下拉选中值 $('#materialMissing').combo('setValue', _value).combo( 'setText', _text); }); });