Solved

Javascript onChange()

Posted on 2004-05-03
4
4,299 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now