SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Melbourne, VIC, AU
    0 Post(s)
    0 Thread(s)

    jquery autocompleter spliting results into two listings


    I have a search box that pulls results from 2 tables in my database (products and manufacturers). the results will be stored in a JSON based data set (concatenate both tables into one dataset) for fast access (and to limit it to 2 hits of the DB).

    This is using the jQuery autocompleter plugin. The search will be based on relevance to the letters being entered. Similar to the searching pane on Apple's website.

    I want to have my autocompleter results pane show the results in two groups: manufacturer and products.

    An example of the functionality would be a search for Dell and the following results returned:

    Dell Inspiron 9660
    Dell PowerEdge 1920
    Dell Vostro 1900

    Dell Computing

    The sticking point would be the best and most efficient way to iterate over the dataset and then split it out into the two ULs that represent the results.

    I was thinking of tagging each entry in the dataset with its table name and then having a sorter run during the returning of the results. Based on the tag, the item would either go in the first or second list.

    Any thoughts?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    The dataset should be split up on the server side before being sent to the client.

    Code "javascript':
        'Products': [
            'Dell Inspiron 9660',
            'Dell PowerEdge 1920',
            'Dell Vostro 1900'
        'Manufacturers': [
            'Dell Computing'
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts