Thursday, April 19, 2012

How to pass option into HTML select

I want different behaviors depending on which <option> element is selected:



<select name="colorSelector" onchange="handleColorChange();">
<option value="">- select -</option>
<option value="1">Red</option>
<option value="2">Blue</option>
</select>

function handleColorChange() {
// Behave different depending on which <option> was just selected
}


What do I need to pass into the handleColorChange() method from inside the onchange listener in order to accomplish this?





No comments:

Post a Comment