<apex:page
controller="AutoComplete">
<script
src="https://code.jquery.com/jquery-1.8.2.js"></script>
<script
src="https://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
<script type="text/javascript">
var j$ = jQuery.noConflict();
var names =[];
<apex:repeat value="{!accounts}"
var="a">
names.push('{!a.name}');
</apex:repeat>
j$(document).ready(function(){
j$("#mydata").autocomplete({
source : names
});
});
</script>
<apex:form >
Account Name<input type="text" id="mydata"/>
</apex:form>
</apex:page>
Class :
public class AutoComplete {
public List<Account> getAccounts(){
return [select id,name from Account limit 25];
}
}
No comments:
Post a Comment