javascript get selected option value onchange

Be the first to rate this post. Store it in a self-attribute (on document ready): Well, why don't you store the current selected value, and when the selected item is changed you will have the old value stored? Why are non-Western countries siding with China in the UN? changed, while onchange occurs when the element loses focus, after the content Any ideas? In JS, to access the previousValue of this select: After you are done using 'previousValue', update the attribute to current value. Now, the onchange event handler is fired whenever a change is made to the select element. Please consider editing the question to include a description about the solution. Beginners are likely to want to access values from a select with the NAME attribute rather than ID attribute. contains all of the options of the select element. This property returns a string representing the value attribute of the <option> element in the list. Thanks for contributing an answer to Stack Overflow! To subscribe to this RSS feed, copy and paste this URL into your RSS reader. This is of course assuming that you prefer to use separate listeners for your set-previous and check-value. onchange event is considered one of the very important property of the GlobalEventHandlers which is part of the EventHandler for making manipulations with the changes in the event. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. How to get the children of the $(this) selector? But that's byond scope of this Q and if you are interested then I can post it also. This only assume the user click the drop down menu. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. pass the id not the text of a drop down list html java. Another approach wich can be handy in some situations, is passing the value of the selected