gripe,
Thanks, that does make sense. Now let me go a few steps farther. Here is the entire perl function I am using to generate this popup calendar:
my $SCRIPT=<<END;
<script language="JavaScript">
var NUM_CENTYEAR = 30;
var BUL_TIMECOMPONENT = false;
var BUL_YEARSCROLL = true;
var calendars = [];
var RE_NUM = /^\-?\d+\$/;
function calendar2(obj_target) {
this.gen_date = cal_gen_date2;
this.gen_time = cal_gen_time2;
this.gen_tsmp = cal_gen_tsmp2;
this.prs_date = cal_prs_date2;
this.prs_time = cal_prs_time2;
this.prs_tsmp = cal_prs_tsmp2;
this.popup = cal_popup2;
if (!obj_target)
return cal_error("Error calling the calendar: no target control specified");
if (obj_target.value == null)
return cal_error("Error calling the calendar: parameter specified is not valid target control");
this.target = obj_target;
this.time_comp = BUL_TIMECOMPONENT;
this.year_scroll = BUL_YEARSCROLL;
this.id = calendars.length;
calendars[this.id] = this;
}
function cal_popup2 (str_datetime) {
this.dt_current = this.prs_tsmp(str_datetime
if (!this.dt_current) return;
var obj_calwindow = window.open(
'calendar.html?datetime=' + this.dt_current.valueOf()+
'Calendar', 'width=200,height='+(this.
',status=no,resizable=no,t
);
obj_calwindow.opener = window;
obj_calwindow.focus();
}
function cal_gen_tsmp2 (dt_datetime) {
return(this.gen_date(dt_da
}
function cal_gen_date2 (dt_datetime) {
return (
(dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "/"
+ (dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "/"
+ dt_datetime.getFullYear()
);
}
function cal_gen_time2 (dt_datetime) {
return (
(dt_datetime.getHours() < 10 ? '0' : '') + dt_datetime.getHours() + ":"
+ (dt_datetime.getMinutes() < 10 ? '0' : '') + (dt_datetime.getMinutes())
+ (dt_datetime.getSeconds() < 10 ? '0' : '') + (dt_datetime.getSeconds())
);
}
function cal_prs_tsmp2 (str_datetime) {
if (!str_datetime)
return (new Date());
if (RE_NUM.exec(str_datetime)
return new Date(str_datetime);
var arr_datetime = str_datetime.split(' ');
return this.prs_time(arr_datetime
}
function cal_prs_date2 (str_date) {
var arr_date = str_date.split('/');
if (arr_date.length != 3) return alert ("Invalid date format: '" + str_date + "' Format accepted is dd-mm-yyyy"); if (!arr_date[1]) return alert ("Invalid date format: '" + str_date + "' No day of month value can be found");
if (!RE_NUM.exec(arr_date[1])
if (!arr_date[0]) return alert ("Invalid date format: '" + str_date + "' No month value can be found");
if (!RE_NUM.exec(arr_date[0])
if (!arr_date[2]) return alert ("Invalid date format: '" + str_date + "' No year value can be found");
if (!RE_NUM.exec(arr_date[2])
var dt_date = new Date();
dt_date.setDate(1);
if (arr_date[0] < 1 || arr_date[0] > 12) return alert ("Invalid month value: '" + arr_date[0] + "' Allowed range is 01-12");
dt_date.setMonth(arr_date[
if (arr_date[2] < 100) arr_date[2] = Number(arr_date[2]) + (arr_date[2] < NUM_CENTYEAR ? 2000 : 1900);
dt_date.setFullYear(arr_da
var dt_numdays = new Date(arr_date[2], arr_date[0], 0);
dt_date.setDate(arr_date[1
if (dt_date.getMonth() != (arr_date[0]-1)) return alert ("Invalid day of month value: '" + arr_date[1] + "' Allowed range is 01-"+dt_numdays.getDate()+
return (dt_date)
}
function cal_prs_time2 (str_time, dt_date) {
if (!dt_date) return null;
var arr_time = String(str_time ? str_time : '').split(':');
if (!arr_time[0]) dt_date.setHours(0);
else if (RE_NUM.exec(arr_time[0]))
if (arr_time[0] < 24) dt_date.setHours(arr_time[
else return cal_error ("Invalid hours value: '" + arr_time[0] + "' Allowed range is 00-23");
else return cal_error ("Invalid hours value: '" + arr_time[0] + "' Allowed values are unsigned integers");
if (!arr_time[1]) dt_date.setMinutes(0);
else if (RE_NUM.exec(arr_time[1]))
if (arr_time[1] < 60) dt_date.setMinutes(arr_tim
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "' Allowed range is 00-59");
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "' Allowed values are unsigned integers");
if (!arr_time[2]) dt_date.setSeconds(0);
else if (RE_NUM.exec(arr_time[2]))
if (arr_time[2] < 60) dt_date.setSeconds(arr_tim
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "' Allowed range is 00-59");
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "' Allowed values are unsigned integers");
dt_date.setMilliseconds(0)
return dt_date;
}
function cal_error (str_message) {
alert (str_message);
return null;
}
</script>
<form name=tstest>
<input type="Text" name="input5" value="">
<a href="javascript:cal5.popu
</form>
<script language="JavaScript">
var cal5 = new calendar2(document.forms['
cal5.year_scroll = true;
cal5.time_comp = false;
</script>
END
print $SCRIPT;
}
This is the entire function I am using to generate my page and includes the javascript to generate the popup. So are you saying I can use one of the templating modules to do all of this somehow?
If so could you provide some direction on how I can do this? For one reason or another I am a bit gun shy towards the template modules.
Thanks
Main Topics
Browse All Topics





by: gripePosted on 2004-11-15 at 06:45:49ID: 12584065
It sounds like you're trying to 'exec()' your HTML file instead of printing it's contents. exec() is for 'executing' other executable programs, such as another perl script. Also, exec() will execute it's argument and -never return-, so the rest of your script will not be completed after a successful exec. If you want to output the contents of the file, you should open() the file and print it's contents, like this:
calendar.h tml' or die $!;
open my $html, '/v/www/cgi-bin/timesheet/
while ( <$html> ) { print; }
You should also consider using a templating module to do this stuff. They are built for your very requirements and have the added bonus of allowing you to include and substitute variables or code blocks within your templates.
Some suggested template modules are:
HTML::Template
Template::Toolkit
Text::Template
Hope that helps.