?
Solved

Javascript onChange()

Posted on 2004-05-03
4
Medium Priority
?
4,313 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 75 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article discusses how to implement server side field validation and display customized error messages to the client.
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…
Suggested Courses

777 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