permaculture playing cards*
The moose likes HTML, CSS and JavaScript and the fly likes can we get previous value that user select in options? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "can we get previous value that user select in options?" Watch "can we get previous value that user select in options?" New topic
Author

can we get previous value that user select in options?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi good day, if i have an option , how to i keep the the previous state/value that user have selected before change to new state/value ,

i have try using hidden to keep it , but is there any better way to do so ?

thank you for guidance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Does this previous value need to be submitted as part of the form? If so, then a hidden element is just fine. If not, you could just store it in a Javascript variable.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi Bear Bibeault , if using javascript variable , and i use document.form.optionname.value , it always take the value of after onchange, how to get the previous value before user change on option ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Store it before the user makes the change. Once it's changed, there's no way to find the previous value.
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
thank you , bear
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can we get previous value that user select in options?
 
Similar Threads
Why do I need AJAX?
Multiple responses to one request
serialization
Using 3rd party API, display tag query regarding Pagination
Embed form element value in scriplet?