Reputation: 3
I have one html table row having dynamic checkboxes with same id in a jsp page and I want to fetch the value of selected checkboxes from this page and use it to another jsp page .I'm using request.getParameter
to fetch the value but I'm getting null in other jsp page.Please suggest me what to do ?
Here is the code where i have dynamic checkbox (index.jsp):
<% for (RecordField recordField : flds) { %>
<tr>
<td width="15" bgcolor="#46A0F0"><input type="checkbox" name="tablechkboxl"
id="fieldName" / ></td>
<td width="200" >
<%= recordField.getFieldName() %> //dynamic fields
<%}
%>
</td></tr>
Now i want to use the selected checboxes value in other jsp as (Submit.jsp):
for (Enumeration e = request.getParameterNames(); e.hasMoreElements();){String[]
checkedcolumns = (String) request.getParameterValues("tablechkboxl");
System.out.println("Now i am getting "+checkedcolumns );
}
But instead of getting name of checked columns i am getting "on".Anyone please suggest.
Upvotes: 0
Views: 1915
Reputation: 769
Selected checkbox has a default value as "on". So you have to override default value of the checkbox.
<input type="checkbox" name="tablechkboxl" value="<%= recordField.getFieldName() %>" />
Upvotes: 1
Reputation: 944425
on
is the default value. If you want a different value then you need to give the input element a value="something"
attribute.
Upvotes: 0