Welcome back from what is hoped was a relaxing break. OK, we're almost there! Without changing the calendar widget code from Reply 9 in the previous thread, following is the code used to implement your suggestion. When the below code executes, it results in an internal server error. Interpreting this to mean that code is not finding the CalendarWidget.pm perl module. Can you discern what my problem could be?
#! /usr/bin/perl -wT
#
use strict; #force all variables to be declared before use
use CGI qw(:standard escape escapeHTML); # most common CGI interface f
+unctions
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); #all diags to bro
+wser
use URI;
use lib qw(/home/gmacfadd/public_html/cgi-bin/Calendar);
use CalendarWidget;
my $selected_date;
my ($get_calendar_widget, $item);
my $choice = lc (param ("choice")); # get choice, lowercased
my $url1 = URI->new('http://www.gmacfadden.com/cgi-bin/Calendar/Calend
+arWidget.pm');
my $url_picture = URI->new('http://www.gmacfadden.com/images/calendar.
+jpg');
my @field_list =
({ name => "selected_date", label => "Select a date:" });
print header (), start_html (-title => "Test CGI Form", -bgcolor => "o
+range");
if ($choice eq "") # initial script invocation
{ display_entry_form (); }
elsif ($choice eq "submit")
{ process_form (\@field_list); }
elsif (defined (param("get_calendar_widget")))
{ if ($get_calendar_widget eq "get_calendar_widget")
{
if ($item eq "item1")
{
my($y1,$m1,$d1)= CalendarWidget::calendar_widget();
print "<br>You selected $y1-$m1-$d1.<br>\n";
$selected_date = $y1."-".$m1."-".$d1;
}
else {}
}
else
{
}
}
else
{ print p (escapeHTML ("Logic error, unknown choice: $choice")); }
print end_html ();
exit (0);
sub display_entry_form
{
my @row; # define array
print start_form (-action => url ()); #default method is POST
push (@row, qq(<table border=3 bordercolor="blue" align="left"
+ bgcolor="xffff00">) );
push (@row, Tr (
( qq(<TD ALIGN="CENTER" VALIGN="TOP" BGCOLOR="yellow" COLSPAN="2">)
+, qq(Please provide the information requested in the table below.)
) ) );
push (@row, Tr (
( qq(<TD ALIGN="RIGHT" VALIGN="TOP">), qq(Select a date:) ),
( qq(<TD ALIGN="LEFT" VALIGN="TOP" BGCOLOR="yellow">),
(textfield (-name => "selected_date", -size => 10
+)),
a({-href=>$url1}, img({-src=>"$url_picture", -alt
+=>"click calendar to select a date"}) ) ) ));
print table (@row),
submit (-name => "choice", -value => "Submit"),
end_form ();
}
sub process_form
{
my $field_ref1 = shift; # reference to field-List
my @errors;
$selected_date = param ('selected_date');
foreach my $f (@{$field_ref1})
{
if ( ($f->{name} eq "selected_date") )
{
push (@errors, $f->{label}) if $selected_date eq
+""; #it's empty!
}
else { }
}
if (@errors)
{
print p ("Some information is missing."
. " Please fill in the following fields:");
s/:$// foreach (@errors); # strip colons from end of labels
print ul (li (\@errors)); # print column names
display_entry_form (); # redisplay entry form
return;
}
print p ("The date entered was $selected_date.<br>\n");
}
|