解决方案 »

  1.   


    <script src="http://code.jquery.com/jquery-1.8.0.js" type="text/javascript"></script>
    <script>
    var text="bb,aa,cc,dd";//把数据库的查找内容用,拼接放这
    $(document).ready(function(){
    //遍历所有checkbox,当其值存在在text中时选中
    $(":checkbox").each(function() {
    text=","+text+",";//防止匹配到bbb
            if(text.indexOf(","+$(this).val()+",")!=-1) $(this).prop("checked",true);
        });
    });
    </script><input type="checkbox" value="aa" />1
    <input type="checkbox" value="bb" />2
    <input type="checkbox" value="bbb" />3
      

  2.   

    写错了,修改一下<script src="http://code.jquery.com/jquery-1.8.0.js" type="text/javascript"></script>
    <script>
    var text="bb,aa,cc,dd";//把数据库的查找内容用,拼接放这
    $(document).ready(function(){
    text=","+text+",";//防止匹配到b
    //遍历所有checkbox,当其值存在在text中时选中
    $(":checkbox").each(function() {
            if(text.indexOf(","+$(this).val()+",")!=-1) $(this).prop("checked",true);
        });
    });
    </script><input type="checkbox" value="aa" />1
    <input type="checkbox" value="bb" />2
    <input type="checkbox" value="b" />3
      

  3.   

    选项都应该是数据库里的,产生html页面时是枚举出来的,
    你可以指定某些ID是选中的
    while($row==mysql_fetch_row($res)){
    if($row['id]==6)
       echo "<input type='checkbox' value=$res['goods_brand']  checked='checked'/>";
    else
       echo "<input type='checkbox' value=$res['goods_brand'] />";
    }
      

  4.   

    看你结构,你应该先用explode(',', goods_brand); 获取到每一个goods_brand
    然后再判断是否与当前的checkbox对应,如果是,加上checked="checked";