• 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 get new and old value in java script method?

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 1845
10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic