Page 1 of 1

filter search results by clicking checkboxes

Posted: Thu May 26, 2011 8:08 am
by barricades
Hey there everyone.

I'm a bit of a newb with php so apologies if this question is a bit simple, although I can't get my head round how to go about doing it.

I have a search page where a user can type in a search box, or they can use an alphabetical list to search for the record they're looking for. Eg they click 'a' and all the records beginning with the letter 'a' appear.

I'd also like to have it so that each record has a number of tags, and I'd then like to be able to filter records according to which tags have been selected - preferably using checkboxes.

For example, perhaps the tags would be colours and the records represented shoes. There'd be checkboxes for blue, yellow, black, brown and so on. At first all colours would be shown, but if the user clicks on brown the all but the brown shoes dissappear.

like I say, I'm new to learning php so please be gentle. Also I'm using Cakephp so if there's anyway to make it easier using Cake then I'd love to know.

thanks ;)

Re: filter search results by clicking checkboxes

Posted: Tue May 31, 2011 9:38 am
by barricades
So I've made the list and been advised that I should use 'observerform' call on the page that runs whenever the form is changed'

I've googled observerform but haven't been able to figure out what exactly to do since I'm totally new to javascript.

Can anyone give me a bit of a road map on how to do this? I don't get how to attach the javascript to the form and how to make it call a function to run the query

I did find http://stackoverflow.com/questions/2417 ... ple-fields which has a bit of javascript which might help but from what I've learned about cakephp there is probably a much better way of doing this.

Re: filter search results by clicking checkboxes

Posted: Wed Jun 01, 2011 3:26 pm
by emelianenko
This is the same answer I have given to a similar case,

Whether you choose checkboxes or a select list, the code is this for the select boxes. The great thing is that it uses Ajax, so there is no need to lose sight of the page or refresh or reload, data updates itself in real time

http://www.w3schools.com/php/php_ajax_database.asp