接上面
比如说 数据库中存储的值为7,如果要取到这个值然后塞到各个checkbox里面更新。
见代码:
如果为7 这3个checkbox都会勾选上。如果值为2 ,只会勾选c2.
比如说 数据库中存储的值为7,如果要取到这个值然后塞到各个checkbox里面更新。
见代码:
<script type="text/javascript" src="scripts/jquery.js">
</script>
<script type="text/javascript">
$("body").ready(function(){
var a=7 //这个值是从数据库中查出的字段
if(a&1) $("#c1").attr("checked",true);
if(a&2) $("#c2").attr("checked",true);
if(a&4) $("#c3").attr("checked",true);
})
</script>
<input type="checkbox" id="c1" value=1/>11<br>
<input type="checkbox" id="c2" value=2/>22<br>
<input type="checkbox" id="c3" value=4/>33<br>
</BODY>
如果为7 这3个checkbox都会勾选上。如果值为2 ,只会勾选c2.