Gossamer Forum
Home : Products : DBMan : Installation :

Setting a search dropdown

Quote Reply
Setting a search dropdown
Hi,

Here is what I have now.

I have search form where the user can search the database. I set the form text box to keyword, so any search that will be done, will search in all the fields. Under that I set a "sb" dropdown list, so the user can specify how they would like to sort the results.

Here is what I want to do.

The actual form box (<INPUT TYPE="TEXT" NAME="" SIZE=15 MAXLENGTH=255> ) will not be keyword, but rather it will look at the dropdown list below it and set that name to what was selected from the dropdown list.

Here is an example. I want to search for the Item #18989, if I type that in the text box I also have to choose Item from the drop down list. If I type in #18989 and have company under the dropdown, I won't get any results.

I hope this makes sense. For some reason I have doubts about getting this to work. Please tell me I'm wrong

Thank You
Quote Reply
Re: Setting a search dropdown In reply to
Let me try to put this in "other words" so I know what you're trying to do.

You want to have a text box where the user enters a search term. Then you want a select field where the user selects the field they want to search on. You also want the results to be sorted by the field that was searched. Is that right?

If so, it's possible to do (I think).

Give the name SearchTerm to the text field. Your select field is named sb and should stay the same.

In db.cgi, sub query, after

local (%sortby);

add

$in{$db_cols[$in{'sb'}]} = $in{'SearchTerm'};

That should do it, although I haven't tested it. You do have to be sure that something will be selected in the sb list, though. I would remove

<OPTION>---

from the select list, so users will know they have to choose something.



------------------
JPD





Quote Reply
Re: Setting a search dropdown In reply to
Hi,

Thanks for your reply.

I won't be needing an "sb". All I'm going to be needing is the field name dropdown list. So as the user enters the search in the text box, they will select what field they want to search it in. i.e. Item, Company, Category, etc... I would also like to have an option to search all fields, so it will search in all fields (kinda like keyword).

Thank You
Quote Reply
Re: Setting a search dropdown In reply to
Okay.

Then create your select field like

<SELECT NAME="SearchIn">
<OPTION>Field1
<OPTION>Field2
<OPTION>Field3
etc.
<OPTION value="keyword">All Fields
</SELECT>

Then use

$in{$in{'SearchIn'}} = $in{'SearchTerm'};



------------------
JPD





Quote Reply
Re: Setting a search dropdown In reply to
Hi,

As usual it works just great, thanks to you.

JFrost

[This message has been edited by JFrost (edited May 17, 1999).]
Quote Reply
Re: Setting a search dropdown In reply to
 Smile You're welcome.


------------------
JPD