Gossamer Forum
Home : Products : DBMan : Customization :

Re: Search time on the time of the search

Quote Reply
Re: Search time on the time of the search In reply to
This took a little thinking. Smile

Add the following to your .cfg file:

Code:

%fancy_select = (
'Open' => [
['---','Open'],
['-1','24 Hours'],
['2500','Closed'],
['0','12:00 midnight'],
['30','12:30 a.m.'],
['100','1:00 a.m.'],
['130','1:30 a.m.'],
['200','2:00 a.m.'],
['230','2:30 a.m.'],
['300','3:00 a.m.'],
['330','3:30 a.m.'],
['400','4:00 a.m.'],
['430','4:30 a.m.'],
['500','5:00 a.m.'],
['530','5:30 a.m.'],
['600','6:00 a.m.'],
['630','6:30 a.m.'],
['700','7:00 a.m.'],
['730','7:30 a.m.'],
['800','8:00 a.m.'],
['830','8:30 a.m.'],
['900','9:00 a.m.'],
['930','9:30 a.m.'],
['1000','10:00 a.m.'],
['1030','10:30 a.m.'],
['1100','11:00 a.m.'],
['1130','11:30 a.m.'],
['1200','12:00 noon'],
['1230','12:30 p.m.'],
['1300','1:00 p.m.'],
['1330','1:30 p.m.'],
['1400','2:00 p.m.'],
['1430','2:30 p.m.'],
['1500','3:00 p.m.'],
['1530','3:30 p.m.'],
['1600','4:00 p.m.'],
['1630','4:30 p.m.'],
['1700','5:00 p.m.'],
['1730','5:30 p.m.'],
['1800','6:00 p.m.'],
['1830','6:30 p.m.'],
['1900','7:00 p.m.'],
['1930','7:30 p.m.'],
['2000','8:00 p.m.'],
['2030','8:30 p.m.'],
['2100','9:00 p.m.'],
['2130','9:30 p.m.'],
['2200','10:00 p.m.'],
['2230','10:30 p.m.'],
['2300','11:00 p.m.'],
['2330','11:30 p.m.']
],
'Close' => [
['---','Close'],
['2500','24 Hours'],
['-1','Closed'],
['2400','12:00 midnight'],
['30','12:30 a.m.'],
['100','1:00 a.m.'],
['130','1:30 a.m.'],
['200','2:00 a.m.'],
['230','2:30 a.m.'],
['300','3:00 a.m.'],
['330','3:30 a.m.'],
['400','4:00 a.m.'],
['430','4:30 a.m.'],
['500','5:00 a.m.'],
['530','5:30 a.m.'],
['600','6:00 a.m.'],
['630','6:30 a.m.'],
['700','7:00 a.m.'],
['730','7:30 a.m.'],
['800','8:00 a.m.'],
['830','8:30 a.m.'],
['900','9:00 a.m.'],
['930','9:30 a.m.'],
['1000','10:00 a.m.'],
['1030','10:30 a.m.'],
['1100','11:00 a.m.'],
['1130','11:30 a.m.'],
['1200','12:00 noon'],
['1230','12:30 p.m.'],
['1300','1:00 p.m.'],
['1330','1:30 p.m.'],
['1400','2:00 p.m.'],
['1430','2:30 p.m.'],
['1500','3:00 p.m.'],
['1530','3:30 p.m.'],
['1600','4:00 p.m.'],
['1630','4:30 p.m.'],
['1700','5:00 p.m.'],
['1730','5:30 p.m.'],
['1800','6:00 p.m.'],
['1830','6:30 p.m.'],
['1900','7:00 p.m.'],
['1930','7:30 p.m.'],
['2000','8:00 p.m.'],
['2030','8:30 p.m.'],
['2100','9:00 p.m.'],
['2130','9:30 p.m.'],
['2200','10:00 p.m.'],
['2230','10:30 p.m.'],
['2300','11:00 p.m.'],
['2330','11:30 p.m.']
]
);
Add the following new subroutine to db.cgi:

Code:

sub build_fancy_select_field {
# --------------------------------------------------------
#
# To call this subroutine from html_record_form, use the following syntax:
#
# print &build_fancy_select_field("FieldName",$rec{'FieldName'},"SelectorName")
#
# Be sure to express the field name *exactly* as it is defined in your .cfg file.
#

my ($field,$compare,$name) = @_;
my ($i);

$output = qq|<SELECT NAME="$field">\n|;
$i = 0;
while ( $fancy_select{$name}[$i][0] ) {
$fancy_select{$name}[$i][0] eq $compare ?
($output .= qq|<OPTION VALUE="$fancy_select{$name}[$i][0]" SELECTED>$fancy_select{$name}[$i][1]\n|) :
($output .= qq|<OPTION VALUE="$fancy_select{$name}[$i][0]">$fancy_select{$name}[$i][1]\n|);
++$i;
}

if ($i) { $output .= "</SELECT>"; }
else { $output = "Incorrect field definition"; }
return $output;
}
Set up your form like this:

Code:

<tr><td>Monday office hours:</td>
<td>&nbsp;|;
print &build_fancy_select_field("Office_mon_open",$rec{'Office_mon_open'},"Open");
print qq|&nbsp;|;
print &build_fancy_select_field("Office_mon_close",$rec{'Office_mon_close'},"Close");
print qq|</td></tr>
Make one of those rows for each day of the week and then make similar rows for the hotline hours.

Then give it a try and see if it works. Smile Don't worry right now about printing out the time correctly. Just be sure the select field gives you the correct values and that, when you modify a record, the select field has the value selected.

JPD
http://www.jpdeni.com/dbman/
Subject Author Views Date
Thread Search time on the time of the search wangs 4057 Jul 3, 2000, 2:05 AM
Thread Re: Search time on the time of the search
JPDeni 3975 Jul 3, 2000, 3:18 AM
Thread Re: Search time on the time of the search
wangs 3960 Jul 3, 2000, 8:01 PM
Thread Re: Search time on the time of the search
JPDeni 3973 Jul 4, 2000, 1:33 AM
Thread Re: Search time on the time of the search
wangs 3959 Jul 4, 2000, 2:49 AM
Thread Re: Search time on the time of the search
JPDeni 3933 Jul 4, 2000, 4:31 AM
Thread Re: Search time on the time of the search
wangs 3964 Jul 4, 2000, 6:20 AM
Thread Re: Search time on the time of the search
JPDeni 3953 Jul 4, 2000, 6:49 AM
Thread Re: Search time on the time of the search
wangs 3944 Jul 4, 2000, 3:31 PM
Thread Re: Search time on the time of the search
JPDeni 3939 Jul 5, 2000, 10:04 AM
Thread Re: Search time on the time of the search
wangs 3960 Jul 5, 2000, 11:24 AM
Thread Re: Search time on the time of the search
JPDeni 3947 Jul 5, 2000, 11:36 AM
Thread Re: Search time on the time of the search
wangs 3929 Jul 5, 2000, 11:52 AM
Thread Re: Search time on the time of the search
wangs 3944 Jul 5, 2000, 11:54 AM
Thread Re: Search time on the time of the search
wangs 3959 Jul 5, 2000, 12:00 PM
Thread Re: Search time on the time of the search
JPDeni 3936 Jul 5, 2000, 12:08 PM
Post Re: Search time on the time of the search
wangs 3936 Jul 5, 2000, 12:14 PM