in reply to Need to use Javascript function in Code

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