Reputation: 33
I'm hoping to create a fairly simple 'filter by multiple checkbox' search tool for a website... and I don't know where to begin with live updating results within a specified div as soon as someone selects/deselects a checkbox.
I hoping to build a filter system similar to this page:
http://thegatewayonline.com/articles/
... I want to have a system where clicking on each checkbox triggers a form submit, which loads results into a specified DIV on the same page.
Do you have any pointers towards, or code snippings, which could help me get started?
I am coding using PHP.
Thank you so much in advance for your help!
Joe
Upvotes: 0
Views: 1476
Reputation: 15389
You'll want to issue an $.ajax
call via jQuery when a checkbox is hit:
$('.checkbox').click(function() {
// ajax call here
});
Within the AJAX call, there is a callback function called success
which contains a data parameter. You can echo
a JSON object from a PHP page (which loads the available articles from your database) and have it passed as this parameter. Then, you simply decode this JSON object and print your content on the page.
JSON Reference: https://developer.mozilla.org/en/JSON
jQuery Ajax: http://api.jquery.com/jQuery.ajax/
Upvotes: 1