aspose file tools*
The moose likes JSP and the fly likes How to get new and old value in java script method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get new and old value in java script method?" Watch "How to get new and old value in java script method?" New topic
Author

How to get new and old value in java script method?

Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
Hi,

Can anyone help me out for this following question,

i have the text field with some value in jsp page with form submit.
when click the submit button, java script is called and get the entered value or default value to
compare and initiate some calculation.
how do i get that value?
i tried the following,
alert("new value--::" +document.forms.xxx.value); -> not giving expected result!!!, i mean old form value, i need this value?
document.getElementById('allure.allureId').value - giving updated value.

Regards,
ganesan
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

:confused:

You're saying that you not able to get a value from this code.

While this code
- giving updated value.
then what is your question?


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Use case: When a user changes a field on the screen I want to compare the newly entered value with the value before the user changed it so that I can do some logic based on the new and old values.

Page loads with "foo" typed into input field
User changes field value to "bar"

The OP wants in javascript to know about "foo", but all that the input field can currently return is "bar" - the value of "foo" is long gone.

If you want to keep it you have to keep track of it yourself.
- store it when the page is loaded
- update it on a input controls onchange event.

this page has some answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get new and old value in java script method?