Reputation: 62
I have a number of check boxes on my JSP page. I need to pass ids of all the check boxes to my servlet so that i can perform some database operations. I thought that i can create an array in my javascript function placed in a different .js file which would store these ids and then pass the array to my servlet. But i m not able to figure out how to apply this concept.
Upvotes: 0
Views: 1071
Reputation: 943220
This type of problem is normally approached with
<input type="checkbox" name="foo" value="1">
<input type="checkbox" name="foo" value="2">
<input type="checkbox" name="foo" value="3">
<input type="checkbox" name="foo" value="4">
And then
String values[]=req.getParameterValues("foo");
Which gives you an array of all the checked values.
Upvotes: 2