Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to retain textbox value after refresh

 
Ranch Hand
Posts: 34
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML textboxes have a "value" property.

<input type="text" name="firstName" value="smee" />
 
Ranch Hand
Posts: 42
  • 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
  • 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!
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<textarea>${ someValue }</textarea>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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 an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic