Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team,
I want a city name by writing the one character.
for example :
i have two textbox in my Web Page that is CityTextbox and State Textbox
if i write the word H ,i want the city started from H that is hyderabad,Himachal Pradesh ... and so on which i am not getting.Please kindly help me, how to get it?
I have the number of city and state in SQL Table.
I have the function as follow:

XML
var cityList = [];
        var stateList = [];

<pre lang="cs">function setFocusLostEvents() {

           $(&#39;#txtCity&#39;).focusout(function () {

               var states = $.grep(cityAndStateList, function (item, index) {

                   return $(&#39;#txtCity&#39;).val().toLowerCase() == item.City.toLowerCase()
               });

               $(&#39;#txtState&#39;).val(&#39;&#39;);
               if (states != null &amp;&amp; states.length &gt; 0) {
                   $(&#39;#txtState&#39;).val(states[0].State);
               }
           });
       }</pre>


function bindStateAndCityDropDown() {
$.each(cityAndStateList, function (i, item) {
cityList.push(item.City);
if ($.inArray(item.State, stateList) < 0) {
stateList.push(item.State);
}
});

$("#txtCity").autocomplete({
source: cityList,
select: function (e, i) {
$("#txtCity").val(i.item.val);
},
minLength: 1
});

$("#txtState").autocomplete({
source: stateList,
select: function (e, i) {
$("#txtState").val(i.item.val);
},
minLength: 1
});
}

Where should i modify the code.
Thanks
Harshal Raut
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900