一个含有checkbox的页面(从数据库读取),我想勾选第1,2,3页的checkbox,然后把它的值取出来,我应该怎么做,这个问题很急,希望大家帮忙,谢谢!

解决方案 »

  1.   

    把它们的值暂时存到session里去,用完了再removeAttribute就是了。
      

  2.   

    具体怎么做?我对session概念不是很清楚
      

  3.   

    个人习惯比较不爱用session,给你两页的代码,你自己修改吧
    <%@ 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>
    </head>
    <script language="javascript">function refushpage(){
    form1.submit();
    }</script><%
    String href1="";
    try{
    String checkbox=request.getParameter("checkbox");
    String checkbox2=request.getParameter("checkbox2");
    String checkbox3=request.getParameter("checkbox3");

    href1="jsp2.jsp?checkbox="+checkbox+"&checkbox2="+checkbox2+"&checkbox3="+checkbox3;
    }catch(Exception e){

    }
    %><body>
    <p>
    <form id="form1" name="form1" method="post" action="jsp2.jsp">
      <label>
      <input type="checkbox" name="checkbox" value="checkbox'value" />
    aaa</label>
      <p>
        <label>
        <input type="checkbox" name="checkbox2" value="checkbox2'value" />
          bbb</label>
      </p>
      <p>
        <label>
        <input type="checkbox" name="checkbox3" value="checkbox3'value" />
          ccc</label>
      </p>
      <p>
        <label>
        <input type="submit" name="Submit" value="下一页" />
        </label>
    </p>
    </form>
    <label></label>
    <p>&nbsp;</p>
    </body></html>
    -------------------------------------------------
    <%@ 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>
    </head><body>
    <%
    String str=(String)request.getParameter("checkbox");
    String str2=(String)request.getParameter("checkbox2");
    String str3=(String)request.getParameter("checkbox3");
    out.println(str);
    out.println("<br>");
    out.println(str2);
    out.println("<br>");
    out.println(str3);
    %>
    </body>
    </html>
      

  4.   

    如果仅仅是回到原本那页,再重新选完(不管是勾选还是去掉勾选),提交,session又会被覆盖了,得到的就是你最后一次操作的结果。
    所以你别的什么也不用作
      

  5.   

    不是太明白,是不是还是要用session?