+ Start a Discussion

Autocomplete is not working in visualforce page




I have used autocomplete plugin for  country field in my VF page. It's not working.


Here's code,


//  controller

public class test extends abc


public static User[] getCityValue()
return [Select Id,City From User];



//  VF Page


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>

var availableTags = new Array();

$(document).ready(function() {


function getCityNames(result,event)
for( var iIndex = 0; iIndex < result.length; iIndex++)
var strCity =result[iIndex].City;
if( strCity != null && strCity.length > 0)
availableTags[iIndex] = strCity;   //   data is getting
var elemClientName = $('input[id$=txtCityId]');  //  Id is getting

$(elemClientName).autocomplete({source: availableTags , delay: 10});


<apex:inputText value="{!Reg.BillingCity}" id="txtCityId" />


Could anybody help me to get through this.





Suresh RaghuramSuresh Raghuram

After going thorugh your code i found


var in for (Var iIndex =0 ...........................)


usually we use integer which are a primitive datatype in apex .


i doubt on var please check with your var.

Suresh RaghuramSuresh Raghuram

sorry i didnt observe it is part of script code


Can you provide more details?  What's not working?  Are there errors?  Javascript console give any clues?