Gossamer Forum
Home : Products : DBMan : Customization :

Checkboxes with multiple values not working??

Quote Reply
Checkboxes with multiple values not working??
Hi,

I am trying to give users the option of describing a specific field by clicking a series of checkboxes to give multiple values. I have created the checkbox in the.cfg file as follows....

%db_checkbox_fields = (
GARDEN => 'Large,Small,Rear,Front,Side,Private,Enclosed,Child Safe,Sunny,South Facing,Easily Maintained',
);

and used the following code in html.pl to generate the required options in the form.

|; print &build_checkbox_field ("GARDEN", "$rec{'GARDEN'}"); print qq|

The idea is that users can describe their gardens using the various parameters rather than type a description in a textbox, but when I add a record, only one of the values is assigned to the field. Is there a way to give a field like this multiple values?????

Thanks in advance,

Mick McG


Quote Reply
Re: Checkboxes with multiple values not working?? In reply to
Quoted from the FAQ noted below, located in the section "Fields" - subsection: Field Definitions & Use

Checkbox fields

Checkboxes are, by nature, not multiple select items. They are an "on/off" switch. Either it is or it isn't. You'll need to make a field for each of your checkbox fields.

Each individual line should end with a comma, with the exception of the last line before ");"

Please note that each checkbox used must also have a corresponding field defined for your database. This will allow people to be able to search for more than one of the options.

Notice how you can define a short name for the field and then when it is displayed as being chosen it will display the longer defined name.

Example:

%db_checkbox_fields = (
'Graphic' => 'Yes',
'Check' => 'Personal Check',
'MO' => 'Money Order',
'Visa' => 'Visa',
'MC' => 'MasterCard',
'AE' => 'American Express'
);

Sample field definition: 'Graphic' => [33,'alpha',0,3,0,'','Yes'],

Sample use in sub html_record_form:

<TR><TD><$font><B>Graphic ?:</B></FONT></TD><TD><$font> <B>|; print &build_checkbox_field("Graphic","$rec{'Graphic'}"); print qq|</B><BR>Check if your are including a graphic.</font></TD></TR>

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Checkboxes with multiple values not working?? In reply to
Thanks for the advice. Maybe just inexperience, but I always thought that Radio buttons allowed an on/off response and that checkboxes allowed multiple choices? For example, with a standard HTML Form, Radio buttons to answer simple Yes/No questions and checkboxes where various options may apply. I know what you are saying as this is how I have got round the problem, however I have almost 70 DB fields and could use a way of cutting this down. What you described virtually means that checkboxes and radio buttons are one and the same?

Any other ideas on how I can cut my number of fields would be appreciated.


Thanks again,
Mick M