• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ganesan Ramakrishnan
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
: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?
 
Stefan Evans
Bartender
Posts: 1784
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic