Note that there are some explanatory texts on larger screens.

plurals
  1. POissue with jsp page - not displaying popup
    text
    copied!<p>I have a code like the below in my jsp which determines the checkboxes selected on my Admin home page. I am using a mix of javascript and java to get and post the data.</p> <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import = "java.sql.*" import = "controller.LoginServlet"%&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Administrator Home Page&lt;/title&gt; &lt;script type="text/javascript"&gt; function getCheckedBoxes(chkboxName) { av = document.getElementsByName("mycheckedbox"); for (var e=0;e&lt;j;e++) { if (av[e].checked==true) { document.write("Checkbox selected is " + av[e]); alert(e + " selected"); }  } } function redirectUser() { var req1 = request.getParameter("subAdd"); var req2 = request.getParameter("subReject"); var frm = document.forms[0]; if(req1 != null &amp;&amp; req1.equals("Add")) { var pageName = "/LoginServlet?method=add"; frm.action = pageName; frm.submit(); } if(req2 != null &amp;&amp; req2.equals("Reject")) { var pageName = "/LoginServlet?method=reject"; frm.action = pageName; frm.submit(); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="Admin_Home" action="LoginServlet" method="post"&gt; &lt;% String user_name = new String(); user_name = request.getParameter("user_name"); %&gt; &lt;font color="green"&gt;Welcome Admin, &lt;% out.println(user_name); %&gt;!!&lt;/font&gt; &lt;table&gt; &lt;% int i; int j = 0; int count = (Integer)request.getAttribute("count"); String[] first_name = new String[1000]; String[] group_name = new String[1000]; first_name = (String[])request.getAttribute("first_name"); group_name = (String[])request.getAttribute("group_name"); for (i=0; i&lt;count; i++) { %&gt; &lt;tr&gt; &lt;td&gt;&lt;font color="black"&gt;&lt;% out.println(first_name[i] + " " + group_name[i]); %&gt;&lt;/font&gt; &lt;input type = 'checkbox' value = &lt;% j++; %&gt; name = 'mycheckedbox'&gt;&lt;/input&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } System.out.println("value of i = " + i); %&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="submit" name="subGetChked" id="subGetChked" value = "Get Checked Checkboxes" onclick="getCheckedBoxes('mycheckedbox')"&gt; &lt;input type="submit" name="subAdd" id="subAdd" value = "Add" onclick="getCheckedBoxes('mycheckedbox')"&gt; &lt;input type="submit" name="subReject" id="subReject" value = "Reject" onclick="getCheckedBoxes('mycheckedbox')"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is not displaying the checkbox selected alert when I run the page. Could you please help me with this?</p> <p>Any help appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload