Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Live Search without divs

    Hey guys and girls,

    I've been looking for a script that basically changes my query whenever I enter something in an input field. I only want this to change in my query upon typing something:

    Code:
    LIKE '$search'
    I have a big page with a lot of code, tables, and so on, and I would like the output of this to change whenver I type something in the input field. I have a grocery list where I can select the groceries I will be needing for the next week. I have a LOT of groceries displayed on one page, within one query, about 120 items. It sucks to always search for the stuff using CTRL+F for example, and I do not want to hit any submit buttons each time I am searching using an input field. I want a live search, something very basic, but what does the job.

    For example, this is how my page looks like after getting the information from the database table:

    Code:
    <table>
    <tr>
    <td>Name</td>
    <td>Age</td>
    <td>E-Mail</td>
    </tr>
    
    <tr>
    <td>Alpha</td>
    <td>25</td>
    <td>alpha@something.com</td>
    </tr>
    
    <tr>
    <td>Bravo</td>
    <td>30</td>
    <td>alpha@something.com</td>
    </tr>
    
    <tr>
    <td>Charlie</td>
    <td>35</td>
    <td>alpha@something.com</td>
    </tr>
    
    </table>
    Now, whenever I type the letter "A" into my input field, I only want this to be displayed (and it should be changing live whenever I type the "A"):

    Code:
    <table>
    <tr>
    <td>Name</td>
    <td>Age</td>
    <td>E-Mail</td>
    </tr>
    
    <tr>
    <td>Alpha</td>
    <td>25</td>
    <td>alpha@something.com</td>
    </tr>
    
    </table>
    But the thing is, I want this to change without hitting any submit buttons. I have found loads of scripts that can do this, but my problem is always that the results are being displayed in a div or in another input field or whatever. I only want my query to change whenever I type something.

    Does anyone have a simple, basic script that can handle this or can someone point me into the right direction? Thanks in advance!!

  • #2
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Maybe easier to explain, I would like to have what google does, display results when you type (Not autocomplete though, just the search results).

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,538
    Thanks
    45
    Thanked 259 Times in 256 Posts
    It is an autocomplete, or works on the same principles. Instead of filling the results into a div positioned according to the input box, you fill them into your page, or a container, or anything. Its the same exact script with a different target location.

    The basics are simple: AJAX. As someone types, you do a query though an AJAX request, take the results of that request and display it to a user. You control whether its an autocomplete or a results.

  • #4
    New Coder
    Join Date
    Apr 2012
    Posts
    89
    Thanks
    15
    Thanked 0 Times in 0 Posts
    Believe me, I have tried. But the thing is, my results are already all displayed. When I am searching, and typing in the input field, I simply want the results to narrow down to the things I am typing.


  •  

    Posting Permissions

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