daynite has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I have a problem with Perl-CGI script. I tried to generate claender on my webpage using some java scripts and its working fine with html

page, but not working with Perl-CGI script. below is my Perl-CGI scipt... i have placed the below script in the path of /cgi-bin/rj/ain/cal.cgi

Below is the cal.cgi script,

#!/usr/bin/perl
use CGI;
print "Content-type:text/html \n\n";
print <<eof;
<html>
<head>
<title>Calender popup</title>
<script type='text/javascript'>
function Go(){return}
</script>
<script type='text/javascript' src='/var/www/html/JS/AnchorPosition.js' language='javascript'></script>
<script type='text/javascript' src='/var/www/html/JS/CalendarPopup.js' language='javascript'></script>
<script type='text/javascript' src='/var/www/html/JS/date.js' language='javascript'></script>
<script type='text/javascript' src='/var/www/html/JS/PopupWindow.js' language='javascript'></script>
<script type='text/javascript' language='javascript'>var cal = new CalendarPopup();</script>
</head>
<body>
<form name="example">
<input ype="text" name="date1" value="" size=25>
<a href="#" onClick="cal.select(document.forms'example'.date1,'anchor1','MM/dd/yyyy'); return false;" name="anchor1" id="anchor1">select</a>
</form>
</body>
<body>
eof

I also tried the above script by stored the *.js files in /cgi-bin/rj/ain/Js/ path but it failed... can any one help me

Replies are listed 'Best First'.
Re: Include js files in Perl-CGI
by Corion (Patriarch) on Apr 21, 2009 at 14:40 UTC
    /var/www/html/JS/AnchorPosition.js

    This is likely not the path by which the file is visible from the outside through your webserver. Ask your webserver administrator what URL your script is visible from and what URLs you need to print so the Javascript files get served by the webserver.

      hi Corion,... thanks for ur reply... i'm root user and i tried the url http://localhost/cgi-bin/rj/ain/cal.cgi .... and when i click the select link on the page its redirecting into http://localhost/cgi-bin/rj/ain/cal.cgi# .... do i need to move js files to some where... can you please give me some detail idea with example....

Re: Include js files in Perl-CGI
by Doron (Initiate) on Apr 21, 2009 at 15:16 UTC

    You need to make a difference between your local file system and URLs.

    Probably you want to use
    <script type='text/javascript' src='/JS/AnchorPosition.js' language='javascript' type='text/javascript'></script>

Re: Include js files in Perl-CGI
by Herkum (Parson) on Apr 21, 2009 at 15:54 UTC

    The perl script is doing what is supposed to do. What you are encountering is a problem with the way you are building your web page. I would suggest that you look at use Firefox (the web browser) and the Web Developer plugin. That would help you identify problems with your HTML.