Skip to main content
Known Participant
March 14, 2009
Question

Jump to search term in a query output...

  • March 14, 2009
  • 2 replies
  • 544 views
Hi,

I have the results of a query outputted in a table. Depending on the user, this can be a longish query - maybe 100+ results. All these results have a checkbox next to them. The user checks the records they need to select, then submits the form to take that list of records in the "check" variable to another page which processes it.

What I'd like to be able to do is provide a search box on top of this table, for the user to type in a search term in the record they want to find. Then, I'd like the page to jump down to that record so the user can check it. But here's the kicker - I don't want to lose any other already-checked boxes. So the form variable needs to persist, even if this is done multiple times.

Any ideas on how this might be accomplished? I don't mind if the search has to be tied just to one field, etc. And I'm not asking anyone to write the code for me. Just point me in the direction of the right technique/technology, if ya can.

Thank you!
    This topic has been closed for replies.

    2 replies

    Inspiring
    March 16, 2009
    Bear in mind that it's JavaScript you'll be writing and not Java, which is better since JavaScript is markedly easier than Java :)!

    As you're outputting each record, you can use an anchor tag, certainly, but you can also assign a unique ID attribute to each element dynamically.

    For example:
    <cfoutput query="myquery">
    <li id="elem#myquery.CurrentRow#_#myquery.lastname#">#myquery.field#</li>
    </cfoutput>

    Good luck and have fun!
    Inspiring
    March 15, 2009
    Hi,

    It might be worth checking out some of the Ajax libraries for this. jQuery ( http://jquery.com) has a plugin called ScrollTo ( http://plugins.jquery.com/project/ScrollTo) that lets you easily scroll to a specific position or element (or other) item on a page. The developer has more details on his site ( http://flesler.blogspot.com/2007/10/jqueryscrollto.html).

    You could use the ScrollTo plugin in concert with one of the Auto Complete plugins for jQuery (one of them: http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/).

    Hope that helps get you started.
    Known Participant
    March 16, 2009
    I knew it was gonna be Ajax / Java. I suck at Java. ;-)

    Looks like it's time to get up to speed with it though, because that looks like it'll do the trick. I'll either have each record create an anchor with the value of the user's last name or something, or maybe I can make each one an object? I'll see what I can figure out.

    Thanks for the pointer!