checkbox jsp problem
843840Jan 28 2003 — edited Jan 29 2003Hello,
Situation:
I a list of checkboxes with the same name but unique value that a user can check if they did something indicated by the checked item. After they check them and click on submit, it goes to a page that then puts a boolean true in a mysql database for the item they checked to indicate they checked the option. When they return to the page, the page uses mysql to see if each item was previously checked and marks it checked if it was.
Problem: What I want is if the user unchecks it and clicks on submit, the next page will receive an attribute showing that a previously checked box was unchecked so that it can then update the mysql database to change the boolean to false. I am royally confused about how to do this. On the next page I was using:
String[] ticket;
ticket = request.getParameterValues("Ticket");
to receive the checkbox settings. Unfortunately, when you uncheck it, it will not (logically) show up.
I also tried:
I created a java bean with a Vector called ticket
protected Vector ticket = new Vector();
and made:
public void setTicket(Vector v) {
ticket = v;
}
public Vector getTicket() {
return ticket;
}
I put the bean in the first page and the second page:
<jsp:useBean id="tkt" scope="session" class="com.bti.ticketBean" />
When I did in the page the form goes:
Vector ticket = tkt.getTicket();
When I checked ticket with ticket.elementAt(1) for example, it was null whether I checked something or not. I think I would have the same problem anyway with unchecked boxes returning no value.
Question:
How can I detect if a user clicks off a checkbox and get that information on the page where the form goes after clicking on submit?
David