私はjqueryマルチセレクトを使用しています。set オプションを選択したいのですが、selected="selected"属性をオプションに書き込むと、複数選択が正しく実行されません。たとえば、2つのオプションが選択されている場合、このオプションの選択を解除した後、選択された数は減りません。このデモではControl 6: With callbackを使用します。
私のJavaScript:
$(document).ready( function() {
$("#identificationMethods").multiSelect( null, function(el) {
...
});
});
私のHTML
<select id="identificationMethods" name="identificationMethods[]" multiple="multiple" style="width: 100px;">
<c:forEach items="${identificationMethodICs}" var="im">
<option <c:if test="${im.selected == true}">selected="selected"</c:if> value="${im.subType}">
${im.subType}
</option>
</c:forEach>
</select>