Webmastersite.net
Register Log In

search for multiple values
am I missing something here?

Comments on search for multiple values

david
Forum Regular

Usergroup: Customer
Joined: Jun 22, 2005

Total Topics: 91
Total Comments: 305
david
Posted Jun 30, 2008 - 8:48 AM:

I have a linkfield called LOCATION. Checkboxes are used to give this field multiple values, such as TOP, DOWN, UP, BOTTOM. These are stored in the database as , TOP, UP, and such.

Is it possible to search for both values? Something like this?


<form action="search.php?action=filter&filled=1&whichtype=links&condition=or" method="post">
<input type="hidden" name="locationcondition" value="like" />
<input type="checkbox" name="locationsearch" value=", TOP" /> TOP
<input type="checkbox" name="locationsearch" value=", UP" /> UP
<input type="checkbox" name="locationsearch" value=", DOWN" /> DOWN
<input type="checkbox" name="locationsearch" value=", BOTTOM" /> BOTTOM


I tried all variations of the condition: and, or, like. I also tried all variations for the 'locationcondition' as well. Nothing.

I either get no result, or both results even though I searched only one of them, or only the result for one of them even though I searched for both. The most interesting thing, is that the ALLVARS and the debug info confirm that only the later checkbox's value is actually submitted. So even if I selected both TOP and BOTTOM, only BOTTOM would be searched for.

Anybody has an advanced search page that has multiple values for a single field?

Thanks
David
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jul 01, 2008 - 12:05 AM:

It's not possible to search the same field twice in a form.
david
Forum Regular

Usergroup: Customer
Joined: Jun 22, 2005

Total Topics: 91
Total Comments: 305
david
Posted Aug 14, 2008 - 12:34 PM:

Hi Paul,

Will this be in v5?

May I propose a solution. Not a pretty one...
Technically, if you have a field that is populated from checkboxes, the DB field will have something like , firstvalue, secondvalue.

So when trying to search for both of them through a search form that has these values presented as checkboxes, you will be really searching for the , secondvalue (since it uses only the last checkbox value for the search).

BUT, if I was to create a text input field, instead of the checkboxes, and enter this:
, firstvalue , secondvalue
into the text field, and make sure that the searchcondition on these is 'or', then it would find the links that have EITHER values. smiling face

Since I am no programmer, I just began searching for ready to use Javascripts to the following:
- grab the values of checkboxes and populate the value of a hidden text field
- make sure that de-checking a checkbox deletes that entry from the value of the hidden text field
- make sure there is a space between the values

That's it. This way, you could search for all of those values.

Can you or anybody write such a javascript? I know I can't, and I can't seem to find one. All I know, is that whoever knows Javascript, this shouldn't take longer than a few hours to implement.

Granted, this isn't a good solution, since people could have Javascript turned off.... But I doubt there are many of those out there in this day of age.

So what do you think?

Thanks
David
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Aug 14, 2008 - 5:24 PM:

No, it's not in version 5. Estimate to add it to v5 as a custom project (in PHP, since my javascript knowledge is pathetic) is 1-3 hours ($50-$150).

name="locationcondition[]" will be necessary to send an array that can be processed.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



Sorry, you don't have permission to post posts. Log in, or register if you haven't yet.