1

I have limited experience with Jquery in general and this is the first time I have tried using the autocomplete. I have defined the ready event as per below (please note I have used a dummy url in my example).

 $(document).ready(function() {
    $("#ELEMENTID").autocomplete({
    source: "example.asp",
    minLength: 3
    });
 });

If my example.asp returns a simple array: ["val1", "val2", val3"]

this works well and the textbox with id "ELEMENTID" updates accordingly. I'm actually using this as a suburb/postcode/state validator. The user will be entering a suburb, and after making their selection I would like to also auto populate the postcode and suburb fields. How can I pass these extra values back in my example.asp, and

How do I then access them through the page that is making the call?

1 Answer 1

1

You can prepare list of dictionaries like this:

[{"label":"some_label", "value":"val1", "postcode": "some_postcode"},
 {"label":"some_label2", "value":"val2", "postcode": "some_postcode2"},
 {"label":"some_label3", "value":"val3", "postcode": "some_postcode3"}]

and set the appriopriate values by using select event:

$(document).ready(function() {
    $("#ELEMENTID").autocomplete({
        source: "example.asp",
        minLength: 3,
        select: function(event, ui) {
            $('#id_postcode').val(ui.item.postcode);
        }
    });
});
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.