• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to retain textbox value after refresh

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<textarea>${ someValue }</textarea>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic