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 and search funcationality

I have a below requirement  ,Need to create a custom object "Custom A"  which will have 2 look fields Account Name and Contact Name
.I need to create a vf page such that if I click on account name it shows me 10 records and a search box that
let me search account by putting 3 alphabets and same funcationality in contact name but it should search contact only related  to selected

I have created a basic code .
Apex class
public class create_employee_mv {
    public List<String> listofAccountName {get;set;}
    public List<String> listofContactFirstName {get;set;}
    public Set<Id> AccId;
    public create_employee_mv(ApexPages.StandardController stdcntrl)
        listofAccountName = new List<String>();
        Accid = new Set<Id>();
        for(Account a : [Select Id, Name,(select Employee_Designation__c from Employee_MVs__r)
                         from Account])


VF page
<apex:page standardController="Employee_MV__c" extensions="create_employee_mv" docType="html-5.0">
        <apex:inputText list="{!listofAccountName}"  /> &nbsp;
        <apex:inputField value="{!Contact_Name__c}"/>

James LoghryJames Loghry
Hi there, if you google for Visualforce autocomplete, you'll find several examples, including this one that should suit your needs:

Generally speaking, you'll need to use javascript within your VF page to handle the auto complete portion.  Everything else is pretty straight forward.

If you're requirement doesn't necessarily have to be Visualforce, you could also look at doing this with a Lightning Component, which is more Javascript-centric.  There are also a few examples on google of Lightning Component auto complete examples, including this one:!/strikeLookup.  Now, the strike example doesn't fit your criteria exactly, so you'd need to download the code from github and futz with it a little bit.

Good luck, and have fun :)
- James
James ,since I am new to coding ,I tried this but not able to there any other way ?