function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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=""></script>
<script type="text/javascript" src=""></script>
<link href="" 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?