passing checkbox values between jsps
I have a problem passing checkbox values from one jsp to the next.
This bit works for the first jsp - The piece of code below creates a check box and populates it with the value "uiaddress" from the database, this is a boolean field. I wish to check or uncheck this value according to whether the customer wishes to receive publicity emails.
boolean uiaddress = false;
uiaddress = SQLResult.getBoolean("uiaddress");
<%
String checked;
if (uiaddress)
checked="CHECKED";
else
checked="UNCHECKED";
StringBuffer box=new StringBuffer();
box.append ("<input type=\"checkbox\"name=\"" +uiaddress+ "\" value=\"yes\" "+ checked + ">");
%>
<%= box.toString()%>
I have been using the following piece of code in the second jsp;
String checked = request.getParameter("uiaddress");
I can't seem to make it bring this value in.
I then want to go ahead, update the database with the new value and display a read only checkbox on the page showing what it was set to in the previous jsp.
Any help would be greatly appreciated.
[1186 byte] By [
CchrisN] at [2007-9-26 3:25:02]

Hi:
Does the problem happen when the checkbox is not checked on the first jsp page? Browsers do not pass a check box parameter in the http request unless it is checked. Not sure if this is the problem that you are encountering.
Ajay
> I have a problem passing checkbox values from one jsp
> to the next.
>
> This bit works for the first jsp - The piece of code
> below creates a check box and populates it with the
> value "uiaddress" from the database, this is a boolean
> field. I wish to check or uncheck this value according
> to whether the customer wishes to receive publicity
> emails.
>
>
> boolean uiaddress = false;
>
> uiaddress = SQLResult.getBoolean("uiaddress");
>
>
> <%
> String checked;
> if (uiaddress)
> checked="CHECKED";
> else
> checked="UNCHECKED";
>
> StringBuffer box=new StringBuffer();
> box.append ("<input type=\"checkbox\"name=\""
> +uiaddress+ "\" value=\"yes\" "+ checked + ">");
> %>
> <%= box.toString()%>
>
>
> I have been using the following piece of code in the
> second jsp;
>
> String checked = request.getParameter("uiaddress");
>
> I can't seem to make it bring this value in.
>
> I then want to go ahead, update the database with the
> new value and display a read only checkbox on the page
> showing what it was set to in the previous jsp.
>
> Any help would be greatly appreciated.
>
JainA at 2007-6-29 11:45:25 >
