I have the following dropdown list box:
<select name="DDLConditional1" size="1">
<option selected="selected">is equal to</option>
<option>begins with</option>
<option onclick="ShowBetween();">is between</option>
<option>is not equal to</option>
<option>is greater than</option>
<option>is less than</option>
</select>
I want to show() a textbox and a label based on someone selecting the “is between” option of the dropdown list.
I have multiples of these dropdowns and all of them will have to do the same thing. In other words I have
DDLConditional1 2 3 4… infinite. I’ve already been able to make the button work that appends new conditionals.
I’d get rid of the inline handler assignment, and use jQuery to manage your handler.
It sounds like the
<select>elements are being dynamically added to the DOM, so this uses jQuery’s.live()method to handle those dynamic elements.Example: http://jsfiddle.net/GPMmJ/
Any time a
<select>that has a name that starts withDDLConditionalis added to the page, thechangehandler will work automatically. It gets the value of what was selected using jQuery’s.val()method, and checks to see if it is thein betweenone.