Link to home
Start Free TrialLog in
Avatar of dsg138
dsg138

asked on

Filtering data with Checkboxes

Experts, I am interested in filtering the results of my dataset based on the user's selections.

I'd like to have check boxes that can be checked or unchecked and will allow my users to add or remove criteria to the search.

I found a site that functions exactly how I want mine to work:
http://www.ajmadison.com/b.php/Side-by-Side;Refrigerators/N~26

From the looks of the URL, it looks like the condition string is added to the URL.  

I'm interested in doing something like this but I can't find any information about how to do this.  I think it's php, but can't tell what else is needed.  Is there AJAX involved?

Has anyone done something like this and would you have any examples of how to do this?

Thanks in advance,

-dsg
Avatar of Unspoken1
Unspoken1

Ajax definatley,
Non ajax approach >>
Just send the checked to a php script via a form and have it search mysql via what has been checked.
I believe the example page is not using ajax. Just like Unspoken1 mentioned, put all the checkboxs in a form, and trigger a form submit if any checkbox is being checked/unchecked using onclick event. The form should be sending to the query function so it made the suitable query and return the result back to the page.
First, it's not ajax, second it's not a checkbox.

They are actually images
http://www.ajmadison.com/phpdocs/ajtest/images/endeca/miltsel_unchecked.gif
with a href locations that are links to process the button pressed
http://www.ajmadison.com/b.php/KitchenAid;Refrigerators/N~26+4294967287
 
Avatar of dsg138

ASKER

Thanks for the feedback.

I've done HREF Locations before, but in this case, it looks like each of the criteria are either added to the string or removed from the string (if it's already added).

So you can have 5 different criteria all on one HREF location.

I'm not sure how to do that part.  

Does anyone have any examples on how to do that?
sure you can have a bunch of criteria, they did some off coding and made it look like part of the url. but in general it's done something like this

selection.php?brand=KitchenAid&Price=500,1000&Color=Black,Stainless
Avatar of dsg138

ASKER

Thanks...

So in your example above:
selection.php?brand=KitchenAid&Price=500,1000&Color=Black,Stainless

Let's say I no longer want Price=500,1000 in my Criteria.
I would click the checkbox icon next to $500 - $1000.

How would I make the HREF dynamically remove that criteria at the same time keeping all the other criteria?
No that link would just NOT have any price variable

selection.php?brand=KitchenAid&Color=Black,Stainless
SOLUTION
Avatar of quincydude
quincydude
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I never noticed the whole page reload, I thought it was ajax, but you can go about it with a non ajax approach. I think the author wants us to write code for him.
Avatar of dsg138

ASKER

QuincyDude,

I did notice that the checkbox'a link changes after each refresh.  And the links change based on the multiple criteria selected.

So really, it would have to remember the Criteria in some kind of String, perhaps $Criteria.

I would first have to check if that value was already added.
If it was, then the link would remove the new criteria, if not, it would add it.
Then each link would be something like $Criteria + (or -) $NewCriteria?

Then the new criteria would be passed to the link at every page refresh?

I want to make sure I understand the basic concept... is that it?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dsg138

ASKER

This makes since.  I think I understand the concept.  Thanks for clarifying it for me.