Gossamer Forum
Home : Products : DBMan : Customization :

Converting from a checkbox to a select box

Quote Reply
Converting from a checkbox to a select box
I have a database that currently has 20 different options that are specified with checkboxes. My client wants to change that to a dropdown box. Here's the problem: Each option is it's own database field. The database used to return any record that matched one or more options. How do I best go about converting from the checkbox to a select box format without re-doing the entire database?

Thanks,
Brad
Quote Reply
Re: Converting from a checkbox to a select box In reply to
 
Quote:
Here's the problem: Each option is it's own database field.

This is a problem...since select fields work for ONE field at a time, I don't see how you could create a drop-down menu for multiple database fields.

Regards,



------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Converting from a checkbox to a select box In reply to
It depends on what you want to do.

You can have multiple selections in a select field. The problem comes with searching.

Let's say your select field has

Apples
Apricots
Grapes
Oranges
Peaches

in it. Someone adds a record and selects

Apples
Grapes
Oranges

This is saved to the .db file as
Apples~~Grapes~~Oranges

Now someone else comes along and wants to find anyone who has Apples and Oranges, so he uses the select list. The script will look for

Apples~~Oranges

and it will not find the record I described above.

With checkboxes, it will find the record.



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






Quote Reply
Re: Converting from a checkbox to a select box In reply to
I have the same question, but in my case the fields are "logical". All values in all fields are either "0" or "1" and they're used for searching only (on value "1")

Hope you can help.

Thanks, Hans

Quote Reply
Re: Converting from a checkbox to a select box In reply to
I'm a little confused as to your question. Can you explain it more fully?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Converting from a checkbox to a select box In reply to
Sorry for not being complete.
To stick with the fruit you mentioned as an example in your reply of April 17 to Brad the following:

Lets say I have a database containing field adresses and the fields:
apples~apricots~grapes~oranges~peaches

Every field contains either the value "0" (false) or "1" (true)

I would like to make a drop down box which shows all labels of a.m. field names, (e.g. field name 'appels' would have label 'Appels'

By choosing 'Appels' the program should than return all addresses that contain the value "1" in the field 'appels' after Submit

Note, I do not need multiple selections

Hope this makes it more clear.

Thanks, Hans

Quote Reply
Re: Converting from a checkbox to a select box In reply to
I'm still not sure I understand, so I'll tell you what I think is going on and you will tell me if I'm right or not. Smile

In your database definition you have something like

Code:
Apples => [0, 'numer', 0, 1, 0, '', ''],
Oranges => [1, 'numer', 0, 1, 0, '', ''],
Peaches => [2, 'numer', 0, 1, 0, '', ''],
Grapes => [3, 'numer', 0, 1, 0, '', ''],
You want a select field on your search form that lists each of these fields. When the user selects an option from the select field, it will search for 1 in the selected fields.

Yes?




JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Converting from a checkbox to a select box In reply to
Yes, with the only exception the fields in my database are 'alpha'.


Quote Reply
Re: Converting from a checkbox to a select box In reply to
Well, I guess it doesn't matter whether the field type is "numer" or "alpha," since you're not going to be sorting on that field.

In your search form, create a select field with the exact names of the fields. Call the select field search_field.

In sub query, after

local (%sortby);

add

Code:

if ($in{'search_field'}) {
$in{$in{'search_field'}} = 1;
}

JPD
http://www.jpdeni.com/dbman/