This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 61071
    
  66

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: 61071
    
  66

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?