![]() ![]() ![]() ![]() |
|||||
|
|||||
樓主 爆米香 ![]()
![]() |
q_1.jsp <form name="form1" METHOD="post" ACTION="q_2.jsp" onSubmit="return check();"> <input type="checkbox" name="checkboxB1-2Y" id="checkbox1" value="1" onClick="choose();" />折扣<br /> <input type="checkbox" name="checkboxB1-2Y" id="checkbox2" value="2" onClick="choose();" />活動<br /> <input type="checkbox" name="checkboxB1-2Y" id="checkbox3" value="3" onClick="choose();" />贈品<br /> <input type="checkbox" name="checkboxB1-2Y" id="checkbox4" value="4" onClick="choose();" />點數<br /> <input type="checkbox" name="checkboxB1-2Y" id="checkbox4" value="5" onClick="choose();" />行銷<br /> <input type="checkbox" name="checkboxB1-2Y" id="checkbox5" value="6" onClick="choose();" />其他<br /> --------------------------------------------------------------------------------------------------------- q_2.jsp 進入此頁面先進行以下判斷 ); } session.setAttribute("Q_1", setValue);//倒入session //out.print(setValue); } catch (Exception e) { System.out.print(e); response.sendRedirect("index.jsp"); } String qb1_2Y=(String) session.getAttribute("Q_1"); if (!qb1_2Y.equals("5")) { response.sendRedirect("q_3.jsp"); } %> 問題就是 假如我選了第六個(其他value=6)的選項與第五個(行銷value=5)的選項時,頁面不會跳轉到q_2.jsp 而是會跳轉到q_3.jsp 我該如何寫才能讓他正確的判斷呢?或是我的寫法有問題有更好的寫法也行。還是應該在q_1用JavaScript判斷呢?
本篇文章發表於2015-05-04 12:11
|
1樓
作者回應
爆米香 ![]() |
q_2.jsp 進入此頁面先進行以下判斷
<% request.setCharacterEncoding("big5"); try { String[] multipleChoose = request.getParameterValues("checkboxB1-2Y");//放置q_1checkbox答案 String setValue = ""; out.println(multipleChoose.length); for (int i = 0; i < multipleChoose.length; i++) { // setValue = setValue + multipleChoose[i]; setValue = multipleChoose[i]; out.println("multipleChoose["+i+"]"+multipleChoose[i]); } session.setAttribute("Q_1", setValue);//倒入session //out.print(setValue); } catch (Exception e) { System.out.print(e); response.sendRedirect("index.jsp"); } String qb1_2Y=(String) session.getAttribute("Q_1"); if (!qb1_2Y.equals("5")) { response.sendRedirect("q_3.jsp"); } %> 上面的q_2.jsp被吃掉了
本篇文章回覆於2015-05-04 12:19
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔-- |
回覆 |
如要回應,請先登入. |