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
Yay for cake! You probably already have prototype and scriptaculous loaded. Now, I'm stuck with a couple of big sites back on 1.1 and 1.2 so my ajax is "old fashioned" compared to yours if you are on cake 1.3 but it's probably still very similar. I'd have my form right at the top and all the check boxes, inputs are in that. Then I'd have a div outside the form for the results. Because you have lots of settings I'd then put an observerform call on the page that runs whenever the form is changed. I normally use observefield but when there are several interacting fields observeform works much better. Now all you need is a function in your controller that sets the layout to an ajax friendly layout, run the query, the view outputs the html for the div contents only and hey presto - you have a really good search function.
Thanks so much for the reply. I'd posted on a couple of forums because I seemed to be getting nowhere but your answer is the clearest I've got. And absolutely yay for Cake. I've been trying to learn it for a month or two now and I absolutely love it.
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/2417542/how-can-i-implement-a-js-o... 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.