0

I am trying to usejquery auto complete. when the autocomplete is requested, I want a value from another textbox to be sent as well. However the value doesnt get sent from the other text box. please help.

HTML:

    <form>
    <input type="text" id="stat" name="stat" />
    <input type="text" id="city" name="city" />
    </form>

jQuery:

    <script type="text/javascript">
    $(function() {
$( "#city" ).autocomplete({
    source:"backend.asp?typ=getcity&stat="+$("#stat").val()
    }); 
    }); 
    </script>
2
  • you should do the .autocomplete on the city whenever the stat has changed. Otherwise it won't get updated. Commented Jun 24, 2013 at 13:20
  • @ Pedro: can you please write the code for me so that I can understand it better. Commented Jun 24, 2013 at 13:24

1 Answer 1

0

Try to use ajax in source like,

$(function(){
    $("#city").autocomplete({
        source: function(request, response) {
            $.ajax({
                url: "backend.asp",
                dataType:'json',
                data: {
                    type: 'getcity',
                    stat: $("#stat").val()
                },
                success: function(data) {
                    response(data);
                }
            });
        },
    });
});

Refer Passing extra parameters to source using Jquery UI autocomplete

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.