Gossamer Forum
Home : Products : DBMan : Customization :

Check box option for hidden field

Quote Reply
Check box option for hidden field
As i come to the near of another project, i find myself Smile? I was wondering how to make the field as an option to be viewed or not? exp Frown A user add his/her name to the add form i would like to have the option of the name to be viewed by the rest of the world) Im kinda new to this so be easy(:
Thanks in Advance!
Quote Reply
Re: Check box option for hidden field In reply to
This is just to decide whether the field value will be displayed, right?

First of all, you need have the autogenerate feature turned off. You'll need to create your own html_record subroutine.

The html_record subroutine will look something like this:

Code:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>
</table>|;
}

Let's say you have a checkbox field called "Checkbox" and that it is where the user decides whether he wants his name printed out. I'll call that field, for want of anything better, "Name."

Alter sub html_record so it looks like this (the changes I've made are in bold print)

Code:
sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>|;
if ($rec{'Checkbox'}) {
print qq|

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
|;
}
print qq|

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>URL: </FONT></TD>
<TD> <$font><A HREF="$rec{'URL'}">$rec{'URL'}</A></Font></TD></TR>
</table>|;
}

If you have any questions, don't hesitate to ask.


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





Quote Reply
Re: Check box option for hidden field In reply to
Dosent work Frown But I had to add somethings its prob in there somewhere?maybe.
anywho heres what i did like u said put the following:
in the sub html record

print qq|
<a href="$db_script_link_url&$db_key=$rec{$db_key}&send_email_form=1">Send e-mail to this Physician</a>
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Physicians ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Posted Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>|;
if ($rec{'Checkbox'}) {print qq|
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>First Name: </FONT></TD>
<TD> <$font>$rec{'Fname'}</Font></TD></TR>|;} print qq|
-------------------------------------------------------------------------
also added on the html default form
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>First Name:</FONT></TD>
<TD VALIGN="TOP"> |; print &build_checkbox_field ("Checkbox","$rec{'Checkbox'}"); print qq|<INPUT TYPE="Text" NAME="Fname" VALUE="$rec{'Fname'}" SIZE="25" MAXLENGTH="255"></TD></TR>
--------------------------------------------------------------------------
Then i added the Checkbox
in default.cfg

# Checkbox fields. Field name => Checkbox value.
%db_checkbox_fields = ( Popular => 'Yes',
Checkbox => 'Yes');

Well, ill keep trying
other note? do i need to build a checkbox for each field or can i use the same one?
Oh ya i almost forgot Congrats!
Thanks JPD- life would be much harder without people like you! Smile

Quote Reply
Re: Check box option for hidden field In reply to
Sorry, I forgot to add it to the %db_def = (
but i could still use the tip , If i need to make a checkbox for each firld or can i group them together some how?
Thanks Agian Smile
Quote Reply
Re: Check box option for hidden field In reply to
You really need to have them in separate checkboxes, especially if you want people to be able to search for more than one of the options.


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