Javascript onChange()

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
sumachaaAsked:
Who is Participating?
 
sachinkaggrawalConnect With a Mentor Commented:
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
 
mark-bCommented:
onChange='alert( this.options[this.selectedIndex].value )'

-Mark
0
 
ZvonkoSystems architectCommented:
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
 
mark-bCommented:
Oops.  I didn't see the that you said 'previous'.  :(
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.