页面上很多checkbox,第一次选择了其中了很多个之后,存如数据库
第二次进到页面,怎么然存入数据库的默认勾上
就是一个回显过程

解决方案 »

  1.   

    每个checkbox肯定有不同的id或value,如果存入数据库中的checkbox 的id(或value)与页面上的checkbox的id(或value)相同,就checked.
      

  2.   

    String checkboxValues = request.getParameterValues("checkbox")
    <input type="checkbox" name="checkbox" value="1"  <%
       for (int i = 0 ;i < checkboxValues .length;i++){
                      if (checkboxValues[i].equals("1") ){
                        out.println("checked");
                           break;
                      }   }%> >1
    <input type="checkbox" name="checkbox" value="2"
       for (int i = 0 ;i < checkboxValues .length;i++){
                      if (checkboxValues[i].equals("2") ){
                        out.println("checked");
                           break;
                      }   }%>>2<input type="checkbox" name="checkbox" value="3">3
      

  3.   

    有2种方法
    1。在标签中加入checked 控制由数据库内容控制
    2。写在js中,页面加载后才可以选中。
      

  4.   

    用ajax吧,让页面不刷新就行了。
      

  5.   

    例子:init
    ReflectionUtils.setFieldVlaue(scheduleForm, "extflg","1".equals(dto.getExtflg()) ? "on" : "");jsp
    <html:checkbox name="ScheduleForm" property="<%=extflg%>" value="on" />update
    String extflg = (String) ReflectionUtils.getFieldVlaue(scheduleForm, "extflg");
    dto.setExtflg("on".equals(extflg) ? "1" : "0");
      

  6.   

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    <!--
    .STYLE3 {
    font-size: xx-large;
    color: #00FF00;
    font-weight: bold;
    }
    -->
    </style>
    </head><body background="527527527.jpg">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p><%
    int n=0;
    String s1=request.getParameter("A");
    String s2=request.getParameter("B");
    String s3=request.getParameter("C");
    String s4=request.getParameter("D");
    String s5=request.getParameter("E");
    String s6=request.getParameterValues("F");
    session.setAttribute("six",s6); 
    String s7=request.getParameterValues("G");
    session.setAttribute("seven",s7); 
    String s8=request.getParameterValues("H");
    session.setAttribute("eight",s8); 
    String s9=request.getParameterValues("I");
    session.setAttribute("nine",s9); 
    %>
    <br>
    <%
    String s6=(String)session.getAttrinbute("six");
    String s7=(String)session.getAttrinbute("seven");
    String s8=(String)session.getAttrinbute("eight");
    String s9=(String)session.getAttrinbute("nine");
    %>
    <%
    if(s1==null)
    {s1="";}
    if(s2==null)
    {s2="";}
    if(s3==null)
    {s3="";}
    if(s4==null)
    {s4="";}
    if(s5==null)
    {s5="";}
    if(s1.equals("a"))
    {n++;}
    if(s2.equals("a"))
    {n++;}
    if(s3.equals("a"))
    {n++;}
    if(s4.equals("c"))
    {n++;}
    if(s5.equals("a"))
    {n++;}
    if(s6.equals("abcef"));
    {n++;}
    if(s7.equals("abc"))
    {n++;}
    if(s8.equals("abef"))
    {n++;}
    if(s9.equals("abcd"))
    {n++;}
    %>
    <p><span class="STYLE3">你的得分为:</span><%=n%>
    </body>
    </html>帮忙看一下这段代码,也是复选的,调试不能通过