al:checkbox根据集合数据源实现多选框
最后更新:2023-09-29 10:01:28
|
状态:未完成
<div class="al-chk-item-border">
<input type="checkbox" value="1" id="lvl_1" checked="checked" name="lvl"/><label for="lvl_1" class="al-chk-item-label">高级</label>
</div>
<div class="al-chk-item-border">
<input type="checkbox" value="2" id="lvl_2" checked="checked" name="lvl"/><label for="lvl_2" class="al-chk-item-label">中级</label>
</div>
<div class="al-chk-item-border">
<input type="checkbox" value="3" id="lvl_3" name="lvl"/><label for="lvl_3" class="al-chk-item-label">初级</label>
</div>
DataSet set = new DataSet();
set.add(DataRow.parseJson("{''ID'':''1'',''NM'':''高级''}"));set.add(DataRow.parseJson("{''ID'':''2'',''NM'':''中级''}"));
set.add(DataRow.parseJson("{''ID'':''3'',''NM'':''初级''}"));
DataSet values = new DataSet();
values.add(DataRow.parseJson("{''ID'':''1''}"));
values.add(DataRow.parseJson("{''ID'':''2''}"));
<al:checkbox data="${set }" name="lvl" value="${values }"></al:checkbox>
这里将根据values中的条目的ID来确定默认选中项