修改资料时候,从数据库获取了由多个checkbox组合的的值:入口商,入口代理,批发商
如何赋值到下面元素上,让它被选中。
<tr>
<td><input id="operation1" type="checkbox" name="inbuyer" value="入口商" onclick="getSelected()"/><label for="CheckBoxList1_0">入口商</label></td>
<td><input id="operation1" type="checkbox" name="inDai" value="入口代理" onclick="getSelected()"/><label for="CheckBoxList1_1">入口代理</label></td>
<td><input id="operation1" type="checkbox" name="Pifa" value="批发商" onclick="getSelected()"/><label for="CheckBoxList1_2">批发商</label></td>
<td><input id="operation1" type="checkbox" name="Liansuo" value="连锁店" onclick="getSelected()"/><label for="CheckBoxList1_3">连锁店</label></td>
<td><input id="operation1" type="checkbox" name="Baihuo" value="百货公司" onclick="getSelected()"/><label for="CheckBoxList1_12">百货公司</label></td>
</tr>
如何赋值到下面元素上,让它被选中。
<tr>
<td><input id="operation1" type="checkbox" name="inbuyer" value="入口商" onclick="getSelected()"/><label for="CheckBoxList1_0">入口商</label></td>
<td><input id="operation1" type="checkbox" name="inDai" value="入口代理" onclick="getSelected()"/><label for="CheckBoxList1_1">入口代理</label></td>
<td><input id="operation1" type="checkbox" name="Pifa" value="批发商" onclick="getSelected()"/><label for="CheckBoxList1_2">批发商</label></td>
<td><input id="operation1" type="checkbox" name="Liansuo" value="连锁店" onclick="getSelected()"/><label for="CheckBoxList1_3">连锁店</label></td>
<td><input id="operation1" type="checkbox" name="Baihuo" value="百货公司" onclick="getSelected()"/><label for="CheckBoxList1_12">百货公司</label></td>
</tr>
document.getElementsByName("inbuyer")[0].value=a[0];
你是想从数据库里获得 入口商 数据赋给入口商的checkbox。。
以此类推
对吗?
$(":checkbox").each(function(){
$(this).attr("checked",true);
})