Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java servlets accepts array of check boxes

Status
Not open for further replies.

786snow

Programmer
Nov 12, 2006
75
0
0
Hi,

is it possible to send array of checkboxes to java sevlet.
In my HTML I do the following

***********

<TR>
<td><INPUT TYPE=checkbox NAME=check_all VALUE=Eh id="check_all[0]">
<b>Select all documents</b></td>
</TR>
<tr>
<td><div class="indent"><input type="checkbox" name="check_all" id="check_all[1]"
value="EZ"/ > Account statements </div></td>
</tr>

<tr>
<td><div class="indent"><input type="checkbox" name="check_all" id="check_all[2]"
value="EA"/ > Account statements </div></td>
</tr>

<tr>
<td><div class="indent"><input type="checkbox" name="check_all" id="check_all[3]"
value="EP"/ > Account statements </div></td>
</tr>

*************

Now when i submit and try to catch thhe values in my java sevlet, Like

String check_all = req.getParameter("check_all[0]");

I get null, like it is not recognizing an array, but if i do

String check_all = req.getParameter("check_all");

I get te value "Eh
 
I think you have to use a loop to do so, there is no smart way to do it.
String myResult[] = new String[4];
for (int i=0;i<4;i++){
myResult = req.getParameter("check_all["+i+"]");
}
There can be null in any element of myResult array if you have to tick any of the checkboxes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top