View Full Version : Jasons Calendar with Perl CGI Script

04-27-2006, 09:08 AM
Hi All,

I'm using Jasons Calendar script with a Perl CGI program (learning Perl at the moment and not that good at it!).

Script: Jason's Date Input Calendar

Apologies if this may have been covered before! I did a quick search but didn't see anything resembling it.

Below is a snippet of code, slightly edited for readability but so that you get the general idea....hopefully...

print $cur->start_form;
print "<table width='48%' border='0'>";
print "<tr>";
print "<td width='18%'>Reference</td>";
print "<td width='23%'>";
print $cur->textfield(-name=>'frm_reference',
print "</td>";
print "</tr>";

print "<tr>";
print "<td>Start Date</td>";
print "<td>";
print "<script>DateInput('frm_startdate',true,'YYYY-MM-DD','$startdate')</script>";
print "</td>";
print "</tr>";

print "<tr>";
print "<td>End Date</td>";
print "<td>";
print "<script>DateInput('frm_enddate',true,'YYYY-MM-DD','$startdate')</script>";
print "</td>";
print "</tr>";

print "<tr>";
# OK OK, I Submit!!!
print "<td>";
print $cur->submit(-name=>'action',
print "</td>";
print "</tr>";
print "</table>";
print $cur->end_form;

When the script executes I get the correct elements displayed and the start date is shown in the date fields properly buy as soon as I click the Add button I get an alert box with the message;

WARNING: the supplied date is not in valid 'YYYY-MM-DD' format: --.
Therefore, the current system date will be used instead: 2006-04-27

I get the message displayed twice which I guess is for the start date and end date boxes, If I press Add again after getting the messages, the message is displayed again.

I want to save the start and end dates so that they can be processed and added into a mysql database, I'm guessing that the date is not being brought back to the CGI script which is why I get 'format: -- ' shown in the error, but I've no idea how to get round it.

Does anyone know how to sort this out in perl CGI or would I do better using a php script (not that I know php yet!).

Any assistance gratefully received.