Gossamer Forum
Home : Products : DBMan : Customization :

build_checkbox_field output

Quote Reply
build_checkbox_field output
 Im having trouble with the output of build_checkbox_field:

In sub html_record_form I use:

<TD VALIGN="TOP"><$font>|; print &build_checkbox_field("Optaget", "$rec{'Optaget'}"); print qq|

and in config:

%db_checkbox_fields = (Optaget => '01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53');

Unfortunately the output $rec{'Optaget'} is shown with bars: 23|24|45|51

that must be interpreted from the "~~" that separates the number in the db-file.

I have no idea how the "~~" got in the db-file- it must be &build_checkbox_field that generates it?

And no idea why these "~~" get interpreted as bars?

I must change this because, if the users think they can/should use bars in the database, it is going to break down.

Do anuone have a solution to this - either how the "~~" get there, or how they are getting translated to bars?
Quote Reply
Re: [poulR] build_checkbox_field output In reply to
The ~~ are converted by the script.

For checkboxes you should have only 1 option not a whole bunch.

Checkbox Bob = Boy
Checkbox Sue = Girl

If you want a bunch then you gotta do this:

%db_checkbox_fields = (
Optaget01 => '01',
Optaget02 => '02',
Optaget03 => '03',
Optaget53 => '53' <--notice there's no comma after last one

and have a separate field in the db for each checkbox. If you don't then you wind up with the ~~ or | issue and that causes problems.

(It's kind of a pain to have that many separate fields, but you have to do it to keep from having problems.)


Last edited by:

Watts: Jan 6, 2004, 3:21 PM
Quote Reply
Re: [Watts] build_checkbox_field output In reply to
I see. I found it now in db.cgi: split_decode and join_encode.

I will go back to a textbox in stead I think - it is a lot of fields to have.

Thank You
Quote Reply
Re: [poulR] build_checkbox_field output In reply to
Or change it to a select list rather than checkboxes.

You can then have a dropdown of choices on the form :)

Unoffical DBMan FAQ

Quote Reply
Re: [LoisC] build_checkbox_field output In reply to
I agree with Lois. You can further enhance it by creating another database holding the items in the drop-down list, thereby enabling you to update any choices very easily.
David Olley
Anglo & Foreign International Limited,

There are 10 types of people in the world: those who understand binary, and those who don't.