Link to home
Start Free TrialLog in
Avatar of keinloffel
keinloffel

asked on

Storing values from a text field

I have a JSP page in which I have:

o One drop down box (Uses SELECT) - Called WorkType
o One Text Field. - Called Description


I also have a JavaBean in which I have instance variables for both WorkType and Description.

Every Time I change the worktype, the page refreshes. The problem I am facing is that I am not able to store what is entered into the description box so that after I refresh, the same description turns up again.

So, if i choose worktype1 and enter in the description: haha
Then if i change the worktype to worktype2, the page refreshes with
worktype = worktype2
description = blank

For every refresh I am able to store what worktype i have, in the bean. This is made much easier by the fact that it uses the SELECT keyword.


<OPTION SELECTED VALUE="<%= workTypes[x][0] %>" > <%= workTypes[x][1] %> </OPTION>
<% sb.setWorkType( workTypes[x][0] ); %>
<% } else { %>
<OPTION VALUE="<%= workTypes[x][0] %>"> <%= workTypes[x][1] %> </OPTION>

the setWorkType does the saving for me.

My problem is that I cannot do the same for description, so that the page remembers what the user wrote, EVEN IF they didnt hit submit. If they had hit submit, i would easily have used request.getParameter and got the description. But here the problem is the user never saves the description at all.

Here's the description line i have so far:

<TD class="main1"><b>Description</b><br><TEXTAREA ROWS=1 COLS=30 NAME="description" ><%= sb.stripTilde(loadDescription) %></TEXTAREA></TD>
<% } %>

I need to be able to somehow say, sb.setDescription like i did for worktype. But I cant pull out whats entered in the box.


Any suggestions???


Thanks!!!!!!
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of damonf
damonf

what client side code to you run onchange of WorkType?  There's no reason you can't do a form submission on behalf of the user.  After all, you ARE making a round trip to the server anyway.  Might as well make it an HTTP POST instead of a GET.  Then you can easily obtain request.getParameter.
Avatar of girionis
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to kennethxu

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer