We are going to learn how to create Autocomplete Text box in visualforce page.
We have to use docType attribute as html-5.0
Controller:
Public class Autocomplete{
public List<String> listOfString {get; set;}
public Autocomplete(){
listOfString = new List<String> ();
for(Account acc: [Select Id, Name from Account]){
listOfString.add(acc.Name);
}
}
}
Visualforce Page:
<apex:page controller="Autocomplete" docType="html-5.0">
<apex:form >
<apex:inputText list="{!listOfString}"/>
</apex:form>
</apex:page>
Preview:
We have to use docType attribute as html-5.0
Controller:
Public class Autocomplete{
public List<String> listOfString {get; set;}
public Autocomplete(){
listOfString = new List<String> ();
for(Account acc: [Select Id, Name from Account]){
listOfString.add(acc.Name);
}
}
}
Visualforce Page:
<apex:page controller="Autocomplete" docType="html-5.0">
<apex:form >
<apex:inputText list="{!listOfString}"/>
</apex:form>
</apex:page>
Preview:
Comments
Post a Comment