File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retain textbox value after refresh

 
smee bond
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple jsp page where I have a textbox. When I enter some data in the textbox and hit 'refresh', the data disappears. Is there a way to retain the textbox data either in jsp/html after refresh? please help!

Thank you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML textboxes have a "value" property.

<input type="text" name="firstName" value="smee" />
 
Jeff Rummings
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If refresh re-submits the form, then yes. You can use the value attribute to retain input's value. For example,

 
smee bond
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not providing the complete details about the problem. Here is the situation:

I have a parent window (not a form, just a plain parent.html) where I have a link (<a href="" />)from which I am opening a child window (child.jsp form). I have a few check boxes on the child. When I select the checkboxes and press submit on child window, the selected values are sent and populated in <textarea /> of parent.html through javascript. Till this point it works fine.
But when I go back to the parent window and press refresh/click on the link to open child window, the value <textarea /> is gone! How do I retain this value? please help. thank you!
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<textarea>${ someValue }</textarea>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't with your current approach.

If the amount of data in the checkboxes is small, instead of setting the values using Javascript directly, use Javascript to refresh the window with the values in the querystring.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic