Gossamer Forum
Home : Products : DBMan : Customization :

Searching multiselect field

Quote Reply
Searching multiselect field
I have the multiselect and multiupload mods working together. I am only having problems when I search using the multiselect field.

Currently, when I search for "AEAA" in the multiselect field the results show all records with "AEAA" as one of the selections and when I search the same field for both "AEAA" and "FIRE" it returns all results that have either of these two selections specified. It seems to be reading the search within the field as an "or" instead of an "and".

When I search for multiple selections in my multiselect field I want the result to have all of the selections, not just one.

What can I do to fix this?
I tried inserting the Boolean mod but I was unsuccessful.

Any other suggestions will be greatly appreciated!

Chris
Quote Reply
Re: [cwhatley] Searching multiselect field In reply to
If you can GUARANTEE the order of the data in your multiselect field, then I came up with a quick and dirty AND boolean search for one of my sites using Javascript to build a hidden regex text field when the form is submitted. The following would allow you to pick any combination of weekdays, and run an AND search on them on one field.

Add the following somehwere above your form...
Code:
<SCRIPT LANGUAGE="JavaScript"><!-- Begin
function formCheck() {
var output;
output = "";
for (var i = 1; i < 8; i++) {
box = eval("document.catform.c" + i);
if (box.checked == true) {
output = output + box.value + ".*";
}
}
document.catform.Category.value = output;
}
// End --></script>

List out your multi-select fields as checkboxes...
Code:
Select Days Open:
<INPUT TYPE=CHECKBOX NAME=c1 VALUE="Sun">Sunday
<INPUT TYPE=CHECKBOX NAME=c2 VALUE="Mon"> Monday
<INPUT TYPE=CHECKBOX NAME=c3 VALUE="Tues"> Tuesday
<INPUT TYPE=CHECKBOX NAME=c4 VALUE="Weds"> Wenesday
<INPUT TYPE=CHECKBOX NAME=c5 VALUE="Thu"> Thursday
<INPUT TYPE=CHECKBOX NAME=c6 VALUE="Fri"> Friday
<INPUT TYPE=CHECKBOX NAME=c7 VALUE="Sat"> Saturday

and don't forget to add the onSubmit to your form tag, your normal hidden fields in addition to the hidden field which you are actually doing the regex search on...
Code:
<form action="$db_script_url" method="GET"
name="catform" onSubmit="return formCheck();">
<input type=hidden name="db" value="yourdb">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden NAME="re" value="1">
<INPUT TYPE=HIDDEN NAME="Category" VALUE="">

Works for me... ;)
[edited for typos... btw I'm not personally using the multiselect mod, but I think I have a decent guess what it does, and this small mod should work for it as well.]

Last edited by:

oldmoney: May 11, 2002, 1:11 AM