Hodaya Shalom
Hodaya Shalom

Reputation: 4417

Fill auto-complete input through JS code

I have an auto-complete input, works great ..

When I fill the content through the JS code, it does not make it in the auto-complete, and I need him to do so.

I tried to put the focus on the input, and run keypress event, it does not work ... What can I do?

Code (which fill in the input):

function FillInput() {
        document.getElementById("MyInput").value ='xxx';
        $('.SearchCities').keypress();
        $('.SearchCities').focus();

    }

Upvotes: 0

Views: 178

Answers (1)

user1726343
user1726343

Reputation:

Try triggering the keyup event instead, as this is what autocomplete listens for. There probably aren't any handlers bound for keypress.

Upvotes: 2

Related Questions