Hello to you all !
I would need your advice and suggestions on how to build the following code. Please note that I am not specifically asking for the full code (!) but I am struggling to get the concepts all perfectly right.
In fact, this post is based on and indirectly follows this one viewtopic.php?t=55295
1. The user enters keywords in a search bar. That's easy ;
2. The corresponding data is retrieved from a database through a standard PHP query. That's OK for me ;
3. Now imagine there is a checkbox next to the search bar, allowing the user to filter the results in step 2 according to the checkbox's criteria. How can I automatically hide or highlight the filtered results without making a new query and without reloading the whole page ? I guess there is some javascript / ajax trick there...
I hope my point is clear enough. Thanks a lot for your help on this.
Hiding specific results from a query
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Yep this is JavaScript. Not sure about the Asynchronous XML part (because the filtering could be done client side unless you wanted to dynamically load later results from the server to maintain a constant item size).
So... do you have a basic understanding of what JavaScript is? How it works? Are you interested in learning how to write it (highly recommended: I don't really deal with AJAX and I've got a working knowledge of JS) or are you looking for something pre-existing to plug in? This would be quite simple to implement, although I'm not proficient enough at JS to bang one out fast.
So... do you have a basic understanding of what JavaScript is? How it works? Are you interested in learning how to write it (highly recommended: I don't really deal with AJAX and I've got a working knowledge of JS) or are you looking for something pre-existing to plug in? This would be quite simple to implement, although I'm not proficient enough at JS to bang one out fast.
Yes I do understand Javascript. Would anyone show me some very simple scripts allowing to do the following :
[0] Table contents :
Column A | Column B
car | blue
car | red
car | blue
truck | blue
truck | red
truck | green
[1] Search bar : looks into column A, and displays results in the following format :
if "car" is sought for :
car | blue
car | red
car | blue
[2] Now imagine there is a checkbox beneath the search bar, allowing the user to select a colour between red, blue and green (or a combination if more than one checked). I have tried to give the same ID (=colour) for each row returned in [1], and then put nothing in the div when a checkbox was unchecked. However, this does not work out (only the first match is hidden) because IDs are unique. Please remember I am trying to automatically update the results table without refreshing the whole page.
Thanks for your help in step [2].
[0] Table contents :
Column A | Column B
car | blue
car | red
car | blue
truck | blue
truck | red
truck | green
[1] Search bar : looks into column A, and displays results in the following format :
if "car" is sought for :
car | blue
car | red
car | blue
[2] Now imagine there is a checkbox beneath the search bar, allowing the user to select a colour between red, blue and green (or a combination if more than one checked). I have tried to give the same ID (=colour) for each row returned in [1], and then put nothing in the div when a checkbox was unchecked. However, this does not work out (only the first match is hidden) because IDs are unique. Please remember I am trying to automatically update the results table without refreshing the whole page.
Thanks for your help in step [2].
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA