The jsp page has multiple check boxes (retrieved from DB),....

<input type="checkbox" name="selecttype" value="<%=rs2.getString("description") %>"/>

I've read these values in to servlet page using

String[] selecttype=request.getParameterValues("selecttype");

the 'selecttype' now contains only selected checkbox values.
but i want to retrieve values of unchecked checkboxes.

Pls help me with this.
Beanboy :-)

Recommended Answers

All 7 Replies

There is no way to get the values of the unchecked checkboxes because when a HTML form is submitted the values of checked checkboxes are sent to the server.

One workaround would be use hidden input fields for storing all the values

<input type="hidden" name="chkboxvalues" value="<%=rs2.getString("description") %>"/>

and in the servlet

String[] selecttype=request.getParameterValues("selecttype");
String[] chkboxvalues=request.getParameterValues("chkboxvalues");

Now use the arrays selecttype[] and chkboxvalues[] to get unchecked values


how to retrieve check box value in html to servlet

durgaselvam: start a new thread.
also realize: html is static. you'll need another language, jsp, jsf, .. but not html.

one question here is that while retrieving the value for multiple input it's not showing which is row selected. Instead it's showing all the values.

anubhavat: well ... duh. which is what was needed to know.
but this thread has been marked solved four years ago. no use reviving it. if you have an actual question, ask it in a new thread.

i have multiple checkboxes they came according to database value.... i want to save the check box value in Database(it's working) but when page reloads after submiting check box value....then i want to show which check boxes are checked ()...their valus wll come from database...any solution??? Thanx in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.