Gossamer Forum
Quote Reply
Search in two fields
Using Andys UltraGlobals, I have the normal search field and now a drop down (Format_Select_Field).
Looks like this:

Code:

<form action="http://www.mysite.com/cgi-bin/links/search.cgi">
<input size="16" type="text" id="searchbox" name="query" value="<%if query%><%escape_html query%><%endif%>" class="text" />

<%Plugins::ULTRAGlobals::Format_Select_Field($Ciudad001,'Ciudad001')%>
<select name="Ciudad001">
<%loop select_loop%>
<option value="<%value%>" <%if selected%>selected="yes"<%endif%>><%name%></option>
<%endloop%>
</select>

<input type="submit" name="Go" value="Buscar" class="submit" />
</form>

Which works fine.

Each of my IDs, have 2 cities. Some only have one, others have two. (Ciudad001 and Ciudad002).
So what ever the person enters in that dropdown, needs to search in both.
Both contain exactly the same item list.

An example can be doctors clinic. They have one clinic in A city, and another in B city.
If I only serach in Ciudad001, Ciudad002 doesnt get listed. So both need to be searched in the same search.

Anyone know how would I go about doing that?

Thanks,

JC
Quote Reply
Re: [Gorospe] Search in two fields In reply to
You should be able to just use multi-select boxes. For example, the query may look like:

query=whatever;Field1=xxxx;Field1=yyyy

...so this would look for the keyword "whatever", and then either Field1 has "xxxx" in it, or "yyyy"

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Search in two fields In reply to
In a regular query I get it and works fine. I dont get exactly where do I place that since the query and the dropdown box are both optional.

Meaning you can search for XXXX everywhere (no drop down box selected), or search for XXX in Miami (xxx being the text field and miami being a drop down that searches in Ciudad001 and ciudad002).

The query can search anywhere with regular weight. Its specificly the dropdown that needs to be searched in both fields.

Where would that go? Is it placed where I marked in red?

Code:

<form action="http://www.site.com/cgi-bin/links/search.cgi">
<input size="16" type="text" id="searchbox" name="query" value="<%if query%><%escape_html query%><%endif%>;Field1=Ciudad001;Field1=Ciudad002" class="text" />

<%Plugins::ULTRAGlobals::Format_Select_Field($Ciudad001,'Ciudad001')%>
<select name="Ciudad001">
<%loop select_loop%>
<option value="<%value%>" <%if selected%>selected="yes"<%endif%>><%name%></option>
<%endloop%>
</select>

<input type="submit" name="Go" value="Buscar" class="submit" />
</form>

JC

Last edited by:

Gorospe: Aug 19, 2010, 4:42 PM
Quote Reply
Re: [Gorospe] Search in two fields In reply to
Hi,

You should just need to change:

Code:
<select name="Ciudad001">

..to:

Code:
<select name="Ciudad001" multiple="yes">

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Search in two fields In reply to
Hmmm, that kills the drop dowm and places a select box with all options shown.

Can one select box function as a select box for two fields?
Quote Reply
Re: [Gorospe] Search in two fields In reply to
Hi,

I'm not about now (just on my way to go camping for a week ;))

I would say that it couldn't be done (unless maybe with some JS code, which upon submitting the form, also set the value of the 2nd field for ya)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Search in two fields In reply to
Okay, I got it to where Im passing the following string to search.cgi

http://www.medicosdeelsalvador.com/cgi-bin/medicos/search.cgi?query=guido&Ciudad002=Ilobasco&Ciudad001=Ilobasco&bool=or

But its not working.
Here is what it should do:
Looking for "guido" in the text box.
When you select something in the select drop down called Ciudad001, it automaticly populates via Javascript Ciudad002.
So what its looking for is for "Ilobasco" in table Ciudad001 and again in Ciudad002
The match should ONLY be found in either or both Ciudad001 or Ciudad002. But not strictly in both, so it should be an boolean OR.
Correct?
Thats the string Im passing, but its not working.
Can anyone help?

Thanks in advance.

Juan Carlos
Quote Reply
Re: [Gorospe] Search in two fields In reply to
Hi,

Mmm, I think the problem is that the "bool" option is actually meant for the "query" value, not the bollean of other fields being passed in.

Maybe worth asking GT is there is a way to do this (I can't think of any)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Gorospe] Search in two fields In reply to
Hi Juan,

This can be temporarily tackled by creating a plugin to hook into the search with hook 'search_set_link_callback'. With this, you can add more "matching links" into the serach results.

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Search in two fields In reply to
Thanks Andy, will try that...

Tandat, sorry, im not a programmer so wouldnt know how. Ill ask GT and see how much THAT will cost me.... :)

JC