I was able to do it with a slight tweak of the code posted here:
http://www.nabble.com/How-to-change-value-of-select-dropdown--tf2308098.html#a6420831


<script type="text/javascript">
jQuery.fn.option = function(value){
        return this.each(function(){
                var select = $(this)[0];
                for(var i = 0; i < select.length; i++) 
                        if(select[i].innerHTML == value) 
                                select.selectedIndex = i;
        });
};

$(function(){
        $('#kwd').keyup(function(){                     
                $('#list').option(this.value);
        });     
});
</script>

<form>
        <input type="text" id="kwd" name="kwd" />
        <select id="list" name="list">
                <option value="0"></option>
                <option value="1">bar</option>
                <option value="2">foo</option>
                <option value="3">far</option>
        </select>
</form>







Brian Litzinger wrote:
> 
> how do I take the value of an text field, and check it against the text in
> a select list? For example, if I type "foo" in a text field, and I have a
> select list that looks like the one below it'll automatically make the
> second option selected.
> 
> <select>
> <option value="1">bar</option>
> <option value="2">foo</option>
> <option value="3">bar</option>
> </select>
> 
> Basically as I type I want to check the value on every key up to see if it
> exists in the select list(not as the value, but the text) then take a
> certain action.
> 



-- 
View this message in context: 
http://www.nabble.com/Not-sure-how-to-do-this...-tf2426822.html#a6768963
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to