Solved

Javascript onChange()

Posted on 2004-05-03
4
4,304 Views
Last Modified: 2008-01-16
hi

is there any way to get the previous value of a list box when calling the onChange function...

i mean i would like to get from which value the onchange is called.....

thx
Sumesh
0
Comment
Question by:sumachaa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:mark-b
ID: 10977655
onChange='alert( this.options[this.selectedIndex].value )'

-Mark
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10977880
No, there is no way.
You have to implement it to your way.
One possible way is to store in the onChange function the actual values as last selected value.
For that you can create a new select object attribute, for example: lastSelected, or lastValue
For the first check you have to loop trough all options and look for the defaultSelected attribute which is set to true.
0
 
LVL 7

Expert Comment

by:mark-b
ID: 10978020
Oops.  I didn't see the that you said 'previous'.  :(
0
 

Accepted Solution

by:
sachinkaggrawal earned 25 total points
ID: 10983896
there r some alternate ways which you can try...although there is no direct way.

what you can do is that u can write function to catch the value before the changes. this you can do in the two ways.

write a function on the on click and on keydown events. these will e fired before onchange.
and catch the value in some hidden fields or in some variables and use them afterwards.

i hope u can understand it.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reactjs with .NET 3 80
Html split(text) Part2 6 25
Table doesn't show the lines! 3 25
REST call Failing 1 16
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question