Gossamer Forum
Home : Products : DBMan : Customization :

Checkbox-Trouble with Preview Record Mod

Quote Reply
Checkbox-Trouble with Preview Record Mod
Dear Forum,

I use JPDenis Preview Mod.

It works very fine unless i have checked more than 1 checkbox in my Checkbox-Fields.

If i check one only, the Preview is fine and the right box is checked; if I check 2 ore more boxes, they all were killed by the preview :o(

Once I've printed the $in{'Typ'}, and it seems to be o.k. It shows me: This~~That~~More ... but the Checkboxes aren't checked.

The Problem ist just in Preview-Mode. It works, if I check them and Click "Add". It works also, when I get a Record for Changing. But they are killed in Preview-Mode.

Can anybody give me a hint? Regards, a.c.h.i.m
Quote Reply
Re: [a.c.h.i.m] Checkbox-Trouble with Preview Record Mod In reply to
Check boxes are meant for one field only and represent on/off yes/no, etc. You shouldn't use multiple checkboxes for the same field or you'll run into trouble....

<INPUT TYPE="checkbox" NAME="Fav_Color_1" VALUE="Red">Red

<INPUT TYPE="checkbox" NAME="Fav_Color_2" VALUE="Green">Green

<INPUT TYPE="checkbox" NAME="Fav_Color_3" VALUE="Blue">Blue

Or if using auto-generate (in default.cfg):

Code:
# Checkbox fields. Field name => Checkbox value.
%db_checkbox_fields = (
Fav_Color_1 => 'Red',
Fav_Color_2 => 'Green',
Fav_Color_3 => 'Blue'
);

(notice that there is no comma after 'Blue')

and then add the fields:

Code:
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 255, 1, '', ''],
URL => [2, 'alpha', 40, 255, 1, 'http://', '^http://'],
Type => [3, 'alpha', 0, 60, 1, '', ''],
Date => [4, 'alpha', 30, 30, 1, &get_date . ' ' . &get_time, ''],
Category => [5, 'alpha', 0, 255, 1, '', ''],
Description => [6, 'alpha', '40x3', 500, 0, '', ''],
Validated => [7, 'alpha', 0, 3, 1, 'Yes', 'Yes|No'],
Fav_Color_1 => [8, 'alpha', 0, 3, 0, '', ''],
Fav_Color_2 => [9, 'alpha', 0, 3, 0, '', ''],
Fav_Color_3 => [10, 'alpha', 0, 3, 0, '', ''],
Userid => [11, 'alpha', -2, 15, 0, '', '']
);

Notice that Userid is now field number 11 this means you would also have to change this line:

Code:
# Auth user field. This is the field position in the database used for storing
# the userid who owns the record. Set to -1 if not used.
$auth_user_field = 9;

To: $auth_user_field = 11;

Helpful Hint: I always make my Userid field the top one (field 0). This helps when manually search thru the default.db file.

Good Luck

.
Quote Reply
Re: [Watts] Checkbox-Trouble with Preview Record Mod In reply to
Dear Watts,

many Thanks, but it seems you meant radiofields, 'cause they are made for On/Off, 1/0 ...

Checkboxes are made for multiple Values. They are separated by ~~ in the Database. Ex.: Green~~Grey~~Red~~Blue

And normaly it works very fine :o(exept the Preview Mode).

Regards, a.c.h.i.m

Last edited by:

a.c.h.i.m: Sep 12, 2003, 2:18 PM
Quote Reply
Re: [a.c.h.i.m] Checkbox-Trouble with Preview Record Mod In reply to
Check out the Unofficial FAQ:

http://redundantcartridge.com/dbman/

to see if the issue has been addressed there as well. Also do a search on this forum for "~~" and see what comes up (pay close attention to the search parameters).

Although you can use checkboxes for multiple items, it's not a good idea.

Good Luck!
Quote Reply
Re: [Watts] Checkbox-Trouble with Preview Record Mod In reply to
Watts is correct.

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.

Radio buttons are generally used to make "Yes/No" choices. Only one choice can be recorded from all available options.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Checkbox-Trouble with Preview Record Mod In reply to
Dear Watts & LoisC,
Thanks for all! I've made a Sprag to my db:
__________________________

Instead of using # print &build_checkbox_field ("Typ", "$rec{'Typ'}");
it works with:

$TKNord = "checked" if ($rec{'Typ'} =~ /TKNord/s);
$MOGO = "checked" if ($rec{'Typ'} =~ /MOGO/s);
$Musik = "checked" if ($rec{'Typ'} =~ /Musik/s);
print qq|
<INPUT TYPE="CHECKBOX" NAME="Typ" VALUE="TKNord" $TKNord> TKNord
<INPUT TYPE="CHECKBOX" NAME="Typ" VALUE="MOGO" $MOGO> MOGO
<INPUT TYPE="CHECKBOX" NAME="Typ" VALUE="Musik" $Musik> Musik
|;
and somethings more like this.
It's not my favored solution (above all I want to realize the Bug) but it works ...
__________________________

I didn't found something on http://redundantcartridge.com/dbman/
about ~~ in DBMan-FAQ-Search;
but it's a really great site with many many Tipps - Thanks to LoisC
__________________________

However, I use multiple checkboxes since 2001, and I got no problems with them.
Maybe the search doesn't work exactly, I don't know -
my searches are prepared and additionally ma-Searches are available.

You are invited to see it work at http://www.burning-out.de/termine
(although its a little modified script)
__________________________

If anybody else can explain me the Preview-Mod-Trouble,
please post it here - I got a Mail than and
I WANT TO REALIZE IT !!!

Cool Greetings @ all, a.c.h.i.m