calling jquery function from a dropdown list -
i have 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 show() textbox , label based on selecting "is between" option of dropdown list. have multiples of these dropdowns , of them have same thing. in other words have ddlconditional1 2 3 4... infinite. i've been able make button work appends new conditionals.
i'd rid of inline handler assignment, , use jquery manage handler.
it sounds <select>
elements being dynamically added dom, uses jquery's .live()
method handle dynamic elements.
example: http://jsfiddle.net/gpmmj/
$(function() { $('select[name^=ddlconditional]').live('change', function() { if( $(this).val() === 'is between') { alert('is between selected'); } }); });
any time <select>
has name starts with ddlconditional
added page, change
handler work automatically. gets value of selected using jquery's .val()
method, , checks see if in between
one.
Comments
Post a Comment