Updating an input value with Jquery

Posted by Evan on Stack Overflow See other posts from Stack Overflow or by Evan
Published on 2010-06-15T07:16:49Z Indexed on 2010/06/15 7:22 UTC
Read the original article Hit count: 230

Filed under:

I have a form with a few fields, one of which should be updated based on the value of another. The value of the first is POSTed to another URL, and the returned value should be used to fill the second field. Here's the code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script>        
    function lookup(rid) {
                    $.get("/handler?rid=" + $("input#rid").val(), function(update_rid){
                        $("#name").val(html(update_rid));
                    })
                }
    </script>
        <form name="new_alert">
            <input type="text" name="rid" id="rid" onkeyup="lookup(this.value);">
            <br />
            <input type="text" name="name" id="name">  
        </form>

The POST works fine, and the correct data is returned from /hander, which I confirmed by making a test and filling it using $("#testdiv").html(update_rid);

So it seems like the problem is in the way I'm trying to update the value, but I can't get past that.

© Stack Overflow or respective owner

Related posts about jQuery