I am trying to make this plug-in work for my scenario. my data is in the following format:
["50986.1 ST SAVINGS BANK", "70625.1-800 GOT JUNK COMMERCIAL SERVICES (USA) LLC", "42755.103RD ST SAND LLC"]
the first part is the id of the company and i need to save that value once the data is selected.
my code:
<script type="text/javascript">
$().ready(function() {
$("#suggest1").focus(function(){
$("#suggest1").autocomplete(cities,
{
formatResult: function(data) {
return data.split(".")[1];
}
});
});
});
</script>
<form autocomplete="off">
<p>
<label>Single City (local):</label>
<input type="text" id="suggest1" />
<input type="hidden" id="suggest1ID"/>
<input type="button" value="Get Value" />
</p>
</form>
Firebug is telling me that "data.split" is not a function. How do i format the result to: a) get the text for the #suggest1 b) get the id and save it in suggest1ID. like: $("#suggest1ID").val(data.split(".")[0]) ?
Oh, one more thing: On the second focus(), is there a way to clean up the first pick from the textbox?
thanks in advance.