Does the HTML "select" element have an on select event? what exactly is the name of the event?
From stackoverflow
J Angwenyi
-
Is
onchangewhat you're looking for?J Angwenyi : fantastic stuff - works!!! thanks guys.From insin -
Regardless of input type, whenever a form input changes value, an
onchangeevent should always be thrown. (With the exception of buttons, as they are not really input devices as such.)insin : Worth noting that when you're using aFrom Ryan McCue -
It's onchange Event.
With jQuery it could be used like this
<html> <head> <script type="text/javascript" src="jquery-1.2.6.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#list").attr("selectedIndex", -1); $("#list").change(function() { $("#answer").text($("#list option:selected").val()); }); }); </script> </head> <body> <div id="answer">No answer</div> <form> Answer <select id="list"> <option value="Answer A">A</option> <option value="Answer B">B</option> <option value="Answer C">C</option> </select> </form> </body> </html>Jeremy Visser : The world is not jQuery. Probably best to respond with a generic JS response if the O.P. didn't explicitly ask for jQuery.Jim G. : +1: I was, in fact, searching for a jQuery solution. Thanks.From Alexander Prokofyev -
It's also worth mentioning that this doesn't fire if the selection doesn't change (seems self explanatory). As far as I know there is no event that fires when a user drops down the selectbox and then reselects the original value.
0 comments:
Post a Comment