in reply to HTML::Template, CGI, passing variables, launching new script

mpeppler nailed it. You must pass your variables from the HTML form to the Perl script using the conventional methods of coding this in the <form> tag:
<form action="cgi-bin/nc1_rpt1_summary.pl" method="post">
I know it's deceiving to see your values supposedly being passed in the URL, but it ain't happening. Your submit can simply be:
<input type="SUBMIT" style="cursor:pointer;cursor:hand;">
BTW, hang in there with HTML::Template, it's a powerful tool for building those dynamic pages.

Good luck.

—Brad
"A little yeast leavens the whole dough."

Replies are listed 'Best First'.
Re: Re: HTML::Template, CGI, passing variables, launching new script
by Lori713 (Pilgrim) on Nov 13, 2003 at 14:12 UTC
    I was hoping the input type="SUBMIT" ... onclick stuff I had at the bottom of nc1_mainmenu.tmpl would allow me to pass the $CGI variables and launch the new .pl page. :-(

    So....

    I made the suggested changes, but I get the following error (which I've seen before but my previous code "seemed" to have eliminated it):

    Can't call method "param" on an undefined value at /local/www/htdocs/scripts/campus/nc1_rpt1_summary.pl line 97.

    Line 97 is about the fifth line up from the bottom of nc1_rpt1_summary.pl ({ my $val = $CGI->param($parm);). It seems to me I've declared my variables, but the program doesn't think so. The newly revised gory details are on my scratch pad since I didn't want to clutter up this post (after this is resolved, I'll post the answer so future super-searchers can find it).

    Is there a better way to do this? I have done some significant reading about recursive vs. iterative, and I think I'd like to go with the iterative variation of launching the new web pages (mostly because of how I'm planning to test this junk). I was trying to make this a small example of how to pass the $CGI variables (I've only got three that I'm trying to track), so I can learn how to use the CGI module along with HTML::Template (which I'm loving, by the way!). I've already got the DBI and DBD::Sybase code working in a separate tiny file.

    Thanks for any insights you can provide. If I can't (relatively) quickly resolve this particular issue, I'll backtrack and take freddo411's advice and using jeffa's example and build a tinier example from there. Thanks!

    Lori

      The error indicates that you are asking for a parameter name that doesn't exist.

      This is a good time/place to learn some basic debugging skills. Start with the line number given in the error. Then trace back to the cause of the problem. In your case you'll start with a var ($parm) that gets set in a loop, that comes from a hard coded array that has to match the text in the HTML. Fix one or the other.

      Other helpful advice: Limit the information in your posts. The long, long listing of the template doesn't really help. Don't include templates unless the problem directly relates to the template. Even if you had to ask for help with a template, don't show us all the HMTL blah,blah,blah. Make a simple version for posting/testing that include the absolute minimum needed stuff. Like this:

      <html> <body> <!-- my_var --> </html> </body>

      -------------------------------------
      Nothing is too wonderful to be true
      -- Michael Faraday