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

hi..i'm working on generating a dynamic calendar on webpage...

the program working fine in html(on desktop), but when i converted

into CGI script the dynamic calender is not working.....

any one please help......

below is my cgi script

<form name="form"> <script language="JavaScript" src="cpy.js" type="text/javascript"></sc +ript> <input type="text" name="textbox"> <a href="javascript: show_cal('document.form.textbox.value')">pick dat +e</a> </form>

and below is the format of cpy.js script..

#!/usr/bin/perl use CGI; print "Content-type:text/html\n\n"; print <<eof; ....java script for calendar... eof

can any one give some suggetion.....

Replies are listed 'Best First'.
Re: Use dynamic stuff in CGI
by marto (Cardinal) on Dec 29, 2009 at 14:23 UTC

    Is there a reason you aren't simply storing plain JavaScript in cpy.js? Also do you have <p> tags in your cpy.js file? You may also want to look at the header() method from the CGI docs.

    Update: You should benefit from reading the links in this post.

    Martin

      hi...thanks a lot for your suggetion...it is working fine...thanks for your links....
      i'm really sorry... there will be no <p> tag...
Re: Use dynamic stuff in CGI
by Unforgiven (Hermit) on Dec 29, 2009 at 14:25 UTC

    Honestly, I'd just suggest you start by reading a tutorial on CGI, or something like that.

    1. That is not a CGI script, that's plain HTML.
    2. That is not a .js (Javascript) file, that's Perl, except with <p> tags before each line. It appears to be meant to generate your javascript, but then I'd ask why. It's static anyway, right? Then there's no need for it.
      hi...thanks a lot for your suggetion...it is working fine...
      i kept original .js file without any perl codes..even it's not working
      i'm sorry for error...there will be no <p> tag
Re: Use dynamic stuff in CGI
by ikegami (Patriarch) on Dec 29, 2009 at 14:57 UTC

    the dynamic calender is not working.....

    What error are you getting in the web server log or in the browser's error console?

      the calender pop up window didn't generate.....
        I have a hard time believing you found that message in either the web server log or in the browser's error console. Perhaps you misread my question?
Re: Use dynamic stuff in CGI
by rowdog (Curate) on Dec 29, 2009 at 18:52 UTC
    print "Content-type:text/html\n\n";

    Javascript is not text/html. Usually JS is application/javascript or text/javascript.

    cpy.js

    .js is an unusual extension for a CGI program. I doubt that your web server is executing cpy.js unless you have tweaked your configuration. I would recommend using an appropriate extension like .cgi.

    Try loading the Javascript directly. http://localhost/cpy.js or whatever. If you get Javascript then you're on your way but I expect you will get a mangled version of the perl script since it's being served as html rather than javascript.

    As ikegami recommends, check the server log and the error console. If you have Firefox around, I'd recommend using a developer addon like Firebug to see what is going on inside the constructed page.

Re: Use dynamic stuff in CGI
by Jenda (Abbot) on Dec 30, 2009 at 17:14 UTC

    Apart from the other problems, keep in mind that <<eof is equivalent to <<"eof" which means that the text enclosed by the heredoc will be handled like a doublequoted string. That is $variables are interpolated, \x escapes are processed etc. etc. ... Maybe the browser doesn't get the text you think it does.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.