Preface: This isn't meant to be a personal attack, just some advice which will almost certainly help you in the future

Please, Please don't use this code. cgi-lib.pl is considered well and truly buried, and with good reason. Check out the following for (some) reasons, and the alternatives: use CGI or die;, No excuses about not using CGI.pm, and you would benefit from reading Ovid's Web Programming with CGI.
The above is a truncated list, and there's plenty of resources around here to help you.

On the more positive side, here's some code which (AFAICT) does what your code does, but will hopefully be more easy to debug, extend, etc.
#!/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); my $database_file_name = "fake.txt"; print header(); print start_html(-title=>"Search Results"); #Open and read in the file open(DATABASE, "<", $database_file_name) or die "Unable to open $database_file_name: $!\n"; my @input_data = <DATABASE>; close(DATABASE); #Get the supplied search term. my $school_search_term = param("School1"); #The HTML table header my @table_rows = th(["Date", "School 1", "Score 1", "School 2", "Score + 2", "Where"]); #Loop through each record, looking for a match. my $num_matches = 0; foreach my $record (@input_data) { my ($id, $date, $where, $school_1, $score_1, $school_2, $score +_2) = split(/\|/, $record); if(lc($school_search_term) eq lc($school_1)) { #We've found a match $num_matches++; push @table_rows, td([$date, $school_1, $score_1, $sch +ool_2, $score_2, $where]); } } #Print the results table, if necessary if($num_matches) { print table(-caption=>"Search Results", Tr(\@table_rows)); print "Found $num_matches matches", br() } else { print b("I'm sorry, no matches were found"), br(); } #Close the html page print end_html;

If you must use JavaScript, then you can use the onLoad, onFocus, etc., attributes to the start_html function. I'm not totally certain about that, because I gave up using JavaScript a long time ago. Check out perldoc CGI for the real answer.

Cheers
davis
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist

In reply to Re: Need to use Javascript function in Code by davis
in thread Need to use Javascript function in Code by mystiko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.