# inputEx - MultiAutoComplete Usage

## Basic MultiAutoComplete creation

Use the following code to create a basic inputEx MultiAutoComplete. (note: this example doesn't work offline)

var field = new inputEx.MultiAutoComplete({ parentEl: 'container1', label: 'Search US state', // see http://developer.yahoo.com/yui/examples/autocomplete/assets/js/states_jsfunction.js for getState function datasource: new YAHOO.widget.DS_JSFunction( getStates), // Format the hidden value (value returned by the form) returnValue: function(oResultItem) { return oResultItem[1]; }, returnLabel: function(oResultItem) { return oResultItem[0]; }, // autocompleter options autoComp: { forceSelection: true, minQueryLength: 2, maxResultsDisplayed: 50, formatResult: function(oResultItem, sQuery) { var sMarkup = oResultItem[0] + " (" + oResultItem[1] + ")"; return sMarkup; } } }); var logDiv = inputEx.cn('div', null, null, ""); YAHOO.util.Dom.get('container1').appendChild(logDiv); field.updatedEvt.subscribe(function(e,params) { var value = YAHOO.lang.JSON.stringify(params[0]); logDiv.appendChild( inputEx.cn('div',null,null,"Updated at "+(new Date())+" "+value) ); });