Does the HTML "select" element have an on select event? what exactly is the name of the event?
fantastic stuff - works!!! thanks guys.
J Angwenyi
2008-10-28 11:52:19
+1
A:
Regardless of input type, whenever a form input changes value, an onchange
event should always be thrown. (With the exception of buttons, as they are not really input devices as such.)
Ryan McCue
2008-10-28 11:48:07
Worth noting that when you're using a <select>, the event is fired immediately on selection, whereas with something like a text input, it's not fired until you move off the field. Checkboxes and radio buttons are fiddly with onchange, so it's best to use onclick for those.
insin
2008-10-28 11:51:02
+3
A:
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>
Alexander Prokofyev
2008-10-28 12:06:53
The world is not jQuery. Probably best to respond with a generic JS response if the O.P. didn't explicitly ask for jQuery.
Jeremy Visser
2009-12-12 00:11:16