Example to get checkbox value:
The example shows how to get the multiple checkbox values from one page to another.To get the checkbox values we take the name of all the checkboxs same.
Here we are taking name as hobbies, the values for all these will be different.
First Page:
Now at next page where we are getting these values we use request object's method getParameterValues(). This method take a string argument which is the name of the checkbox. at the first page. It returns an array of String, which contains the values of the checkboxes which are checked.Select Your Choice Here:-
Second Page:
Your Hobbies are:-
<% String hobbies[] = request.getParameterValues("hobbies"); for (String hobby : hobbies) { out.println("" + hobby + ""); } %>
No comments:
Post a Comment