views:

90

answers:

2

Hi,

I´ve got a Jquery autocomplete input like the following:

$("#cities").autocomplete(regionIDs, {
                    minChars: 2,
                    width: 310,                     
                    autoFill: true,
                    matchContains: "word",
                    formatItem: function(row) {
                        return row.city + ", " + "<span>" + row.country + "</span>";
                    },
                    formatMatch: function(row) {
                        return row.city;
                    },
                    formatResult: function(row) {
                        return row.city + ", " + row.country;
                    }
            });

A listener for the input

$("#cities").result(function(event, data, formatted) {
                    selectedCity = (data.regionID);
            });

And the input:

<input type="text" class="textbox" id="cities" name="q" autocomplete="off">

The trouble is when I reload the page, Internet explorer displays last user Input in the text box. However, the variable has no value.

I have tried with .reset() but no success.

Any ideas why ?

A: 

It's because most (if not all) of the current generation browsers are so "smart" that they retain form values when you reload a page.

Take a look at this question which is about the same subject, maybe you can use this answer to solve your problem.

Prutswonder
Thanks for your answer, I´ve just added at the end of body <script type="text/javascript"> document.getElementById('cities').value ='';</script>No success, I refresh the page in internet explorer and previously selected text is still there.
Matias
+1  A: 

Ok ,, i will answer my own question since i found the solution.

$('#cities').val('');

Thanks everyone !!

Matias