Gossamer Forum
Home : Products : DBMan : Installation :

Find by same field different Radio Buttons

Quote Reply
Find by same field different Radio Buttons
Hi JP

How can I put in a search string to find on the same field but only on 3 of the 5 items I have in radio buttons of that field?

Regards.
Quote Reply
Re: Find by same field different Radio Buttons In reply to
Can you give me an example of what you want to do? I don't understand.


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





Quote Reply
Re: Find by same field different Radio Buttons In reply to
For example:

I have one field called Type where there are 5 radio buttons: Cows, Horses, Cats, Dogs & Birds.

Now I want to make a search for all but leave out Dogs & Birds.

The find is only on Cows, Horses & Cats.

When entering a new record I can only enter one, that's the reason for the radio button, but when finding I need tofand by all or a few.

Regards.
Quote Reply
Re: Find by same field different Radio Buttons In reply to
This is off the top of my head, so possibly I'll come up with another solution later. But this is all I can think of (after thinking "It can't be done!").

You would need to have a separate form for searching. (If you don't know how to make a separate form, let me know and I'll explain it.) In the search form, create checkboxes for each of the possibilities and name them all the same -- the name of your field. They would look something like this:

Code:
<input type="checkbox" name="Type" value="Cows">Cows<BR>
<input type="checkbox" name="Type" value="Horses">Horses<BR>
<input type="checkbox" name="Type" value="Cats">Cats<BR>
<input type="checkbox" name="Type" value="Dogs">Dogs<BR>
<input type="checkbox" name="Type" value="Birds">Birds

In db.cgi, sub query, after

local (%sortby);

add

Code:
foreach $col (@db_cols) {
if ($in{$col} =~ /~~/) {
$in{$col} =~ s/~~/|/g;
$in{'re'} = 1;
}
}

You also will want to make a little change in sub parse_form.

after

if ($value eq "---") { next PAIR; }

add

unless ($value) { next PAIR; }

Now, understand that like most of the things I give folks, this is a guess. I have used the change in parse_form and I tested the new lines for sub query on my home computer. I think it should work.


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





Quote Reply
Re: Find by same field different Radio Buttons In reply to
Thanks JP.

Your idea is great. But I forgot to tell you that the search is through a reference in a button thre will be no form to fill out.

The search will be direct with a <Href and All I want is the table which I have already created with the "find All"

All I need is the way to write the search string. http://www.xxx.com/cgi-bin/....etc
Quote Reply
Re: Find by same field different Radio Buttons In reply to
Oh. Well, let's see.

If the string is within DBMan, use

<a href="$db_script_link_url&Type=Cows%7Horses%7Cats&re=1&view_records=1">

If it's on a static html page, use

<a href=http://url/to/db.cgi?db=default&uid=default&Type=Cows%7Horses%7Cats&re=1&view_records=1">

Basically what you need to do is place a %7 between the options and add &re=1 to your URL. (%7 is the code for the pipe character and &re=1 tells DBMan that you are looking for a regular expression.)

You won't need to make any changes to the script.


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





Quote Reply
Re: Find by same field different Radio Buttons In reply to
Hi JP.

I tried what you said but I am getting an error.

For example I am trying to test the search directly through the url entering:
http://www.camposycampos.com/cgi-bin/db.cgi?uid=default&sb=4&Mer=Vta&Tipo=Casa%7Apto%7PH%7TH&re=1&view_records=1

which is the search string I want in the button later but something is happening and the "%7" is being automaticaly changed for "%257" and getting back "no records found".

Heeelp!

BrianL
Quote Reply
Re: Find by same field different Radio Buttons In reply to
Sorry. I had misread the code when I tried it on my site.

Every place where you used %7, try using %7C.



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





Quote Reply
Re: Find by same field different Radio Buttons In reply to
Thanks!

I'll give it a try