Ok, so I solved my first problem- searching two strings at the same time, using the following code:
<script type="text/javascript"> $(function(){ var data = [ {symbol:'APP', name:'Merrill Lynch & Co Inc', url:'snapshot.php'}, {symbol:'AAPL', name:'Apple Inc', url: 'snapshot.php'}, {symbol:'AMAT', name:'Applied Materials Inc', url: 'snapshot.php'}, {symbol:'AAPI', name:'Advanced Plt Pharmaceuticals Inc', url: 'snapshot.php'}, {symbol:'AMCC', name:'Applied Micro Circuits Corp', url: 'snapshot.php'} ]; $("#searchbox").autocomplete(data, { width: 250, matchContains: true, formatItem: function(row) { return "<span class='resultTickerSymbol'>" + row['symbol'] + "</ span>" + row['name']; }, formatResult: function(row) { return row['symbol']; } }); }); </script> Now, all I need to do is figure out how to add another div or cell at the bottom of the autocomplete box where I can put a disclaimer. Anyone know of a way? On Feb 10, 11:31 am, Gellpak <gell...@gmail.com> wrote: > I'm trying to build a stock symbol search field that will search both > the symbol and the full name of the company. For example, search both > "AAPL" and "Apple Inc", or "AMCC" and "Applied Micro Circuits Corp", > and display both in the same row with character highlighting as in the > usual autocomplete plugin. I'm still learning jQuery so this may be > something simple, but here's my code. > > <script type="text/javascript"> > $(function(){ > function formatItem(row) { > return row[0] + " (<strong>id: " + > row[1] + "</strong>)"; > } > function formatResult(row) { > return row[0].replace(/(<.+?>)/gi, > ''); > } > > var data = [ > {text:'APP', name:'Merrill Lynch & Co Inc', > url:'snapshot.php'}, > {text:'AAPL', name:'Apple Inc', url: > 'snapshot.php'}, > {text:'AMAT', name:'Applied Materials Inc', > url: > 'snapshot.php'}, > {text:'AAPI', name:'Advanced Plt > Pharmaceuticals Inc', url: > 'snapshot.php'}, > {text:'AMCC', name:'Applied Micro Circuits > Corp', url: > 'snapshot.php'} > ]; > $("#searchbox").autocomplete(data, { > formatItem: function(item) { > return item.text; > } > }).result(function(event, item) { > location.href = item.url; > }); > }); > </script> > > And for the html I just have an input box: <input type="text" > id="searchbox"> > > I have it working displaying the 'text' element of the array, but it > ignores the 'name' element I added to the example code from the plugin > page. > > 2ND QUESTION: > I want to add a row at the bottom of the autocomplete list that never > changes, how do I append to the results list?