T
Tommo
Hello All,
I am a still learning so be easy on me. I am trying to get
some code to work that is using JS and Perl/CGI, I am using AS Perl
and an Apache Server on XP as the webserver. Can anyone take a look at
the code and tell me why I am getting Apache Server errors in the code
below (Part A), when I modify the code as shown in part B the errors
go but the JS does not run ??
Part A.
#!D:\Perl\bin\perl
use CGI qwstandard);
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>PROJECT ONE</TITLE>";
print "<SCRIPT LANGUAGE = \"JavaScript\">";
var SelectedParamArray = new Array();
var HorseStatValues = new Array();
function Statistics(count, entry)
{
alert (count+entry);
HorseStatValues[count] = entry;
alert (\"HorseStat = \"+HorseStatValues[count]);
return[false];
}
function Select(elemName, numElements)
{
var SelectedParameter =
document.getElementById(elemName).options[document.getElementById(elemName).selectedIndex].text;
alert ("Params = "+numElements+"##Box = "+elemName+"##Value =
"+SelectedParameter);
SelectedParamArray[elemName] = SelectedParameter;
alert ("Stored Array Value = "+SelectedParamArray[3]);
}
print "</SCRIPT></HEAD>\n";
print "<body bgcolor = \"#2000E2\">";
print "<p align=center><b><font face=Verdana color=\"#FFFF80\"
size=\"4\"> PROJECT ONE</font></b></p>";
print "<p align=center><font color=\"#FFFFFF\">HORSE
STATISTICS</font></p>";
print "<p align=center><select name =\"stats\" size=\"5\">";
$entrycount = 1;
open(RD,"C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\horse.txt");
while ($stats = <RD>)
{
$total = 0;
@stats = split(",", $stats);
$TotalStats = $#stats;
for ($length=1; $length<=$#stats; $length++)
{
$total = $total + @stats[$length];
}
$HorseStatsHash{$total} = $stats;
$entrycount++;
}
close(RD);
foreach $total (sort {$b<=>$a} keys %HorseStatsHash)
{
print "<option value = $HorseStatsHash{$total}>
$HorseStatsHash{$total} = $total</option>";
}
print "</select></p>";
#
#
print "<br>";
print "<p align=center><font color=\"#FFFFFF\">KEY</font></p>";
print "<p align=center><select name = \"key\" size=\"5\">";
$paramcount = 1;
open(MT,"C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\params.txt");
while ($keys = <MT>)
{
print "<option value=$keys> $paramcount = $keys</option>";
$paramcount++;
}
print "</select></p>";
close(MT);
print "<p align=center><font color=\"#FFFFFF\">PARAMETERS</font></p>";
print "<br>";
$int = 0;
$test = 1;
@values = (1,2,3,4,5,7,8,9,10);
for ($length2=1; $length2<=$TotalStats; $length2++) {
print "<font color=\"#FFFFFF\"> $test> </font>";
print "<select name = $test size=\"5\" onclick = Select('$test',
'$TotalStats')>";
for ($length=0; $length<=$#values; $length++) {
print "<option value=@values[$length]>
@values[$length]</option>";
}
print "</select></td>";
if ($int == 13) {
$int = 0;
print "<br>";
print "<br>";
}
$int++;
$test++;
}
print "</body>";
print "</HTML>";
If I change the JS part of the code to look like like below then I do
not get any errors even from command line, the page loads ok but I do
not get any of the Alert popups so I presume that the JS is not being
run ???
Part B.
print "<SCRIPT LANGUAGE = \"JavaScript\">\n";
print "var SelectedParamArray = new Array()\n";
print "var HorseStatValues = new Array()\n";
print "function Statistics(count, entry)\n";
print "{\n";
print "alert (count+entry)\n";
print "HorseStatValues[count] = entry\n";
print "alert (\"HorseStat = \"+HorseStatValues[count])\n";
print "return[false]\n";
print "}\n";
print "function Select(elemName, numElements)\n";
print "{\n";
print "var SelectedParameter =
document.getElementById(elemName).options[document.getElementById(elemName).selectedIndex].text\n";
print "alert (\"Params = \"+numElements+\"##Box =
\"+elemName+\"##Value = \"+SelectedParameter)\n";
print "SelectedParamArray[elemName] = SelectedParameter\n";
print "alert (\"Stored Array Value = \"+SelectedParamArray[3])\n";
print "}\n";
print "</SCRIPT></HEAD>\n";
I am a still learning so be easy on me. I am trying to get
some code to work that is using JS and Perl/CGI, I am using AS Perl
and an Apache Server on XP as the webserver. Can anyone take a look at
the code and tell me why I am getting Apache Server errors in the code
below (Part A), when I modify the code as shown in part B the errors
go but the JS does not run ??
Part A.
#!D:\Perl\bin\perl
use CGI qwstandard);
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>PROJECT ONE</TITLE>";
print "<SCRIPT LANGUAGE = \"JavaScript\">";
var SelectedParamArray = new Array();
var HorseStatValues = new Array();
function Statistics(count, entry)
{
alert (count+entry);
HorseStatValues[count] = entry;
alert (\"HorseStat = \"+HorseStatValues[count]);
return[false];
}
function Select(elemName, numElements)
{
var SelectedParameter =
document.getElementById(elemName).options[document.getElementById(elemName).selectedIndex].text;
alert ("Params = "+numElements+"##Box = "+elemName+"##Value =
"+SelectedParameter);
SelectedParamArray[elemName] = SelectedParameter;
alert ("Stored Array Value = "+SelectedParamArray[3]);
}
print "</SCRIPT></HEAD>\n";
print "<body bgcolor = \"#2000E2\">";
print "<p align=center><b><font face=Verdana color=\"#FFFF80\"
size=\"4\"> PROJECT ONE</font></b></p>";
print "<p align=center><font color=\"#FFFFFF\">HORSE
STATISTICS</font></p>";
print "<p align=center><select name =\"stats\" size=\"5\">";
$entrycount = 1;
open(RD,"C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\horse.txt");
while ($stats = <RD>)
{
$total = 0;
@stats = split(",", $stats);
$TotalStats = $#stats;
for ($length=1; $length<=$#stats; $length++)
{
$total = $total + @stats[$length];
}
$HorseStatsHash{$total} = $stats;
$entrycount++;
}
close(RD);
foreach $total (sort {$b<=>$a} keys %HorseStatsHash)
{
print "<option value = $HorseStatsHash{$total}>
$HorseStatsHash{$total} = $total</option>";
}
print "</select></p>";
#
#
print "<br>";
print "<p align=center><font color=\"#FFFFFF\">KEY</font></p>";
print "<p align=center><select name = \"key\" size=\"5\">";
$paramcount = 1;
open(MT,"C:\\Program Files\\Apache
Group\\Apache2\\htdocs\\params.txt");
while ($keys = <MT>)
{
print "<option value=$keys> $paramcount = $keys</option>";
$paramcount++;
}
print "</select></p>";
close(MT);
print "<p align=center><font color=\"#FFFFFF\">PARAMETERS</font></p>";
print "<br>";
$int = 0;
$test = 1;
@values = (1,2,3,4,5,7,8,9,10);
for ($length2=1; $length2<=$TotalStats; $length2++) {
print "<font color=\"#FFFFFF\"> $test> </font>";
print "<select name = $test size=\"5\" onclick = Select('$test',
'$TotalStats')>";
for ($length=0; $length<=$#values; $length++) {
print "<option value=@values[$length]>
@values[$length]</option>";
}
print "</select></td>";
if ($int == 13) {
$int = 0;
print "<br>";
print "<br>";
}
$int++;
$test++;
}
print "</body>";
print "</HTML>";
If I change the JS part of the code to look like like below then I do
not get any errors even from command line, the page loads ok but I do
not get any of the Alert popups so I presume that the JS is not being
run ???
Part B.
print "<SCRIPT LANGUAGE = \"JavaScript\">\n";
print "var SelectedParamArray = new Array()\n";
print "var HorseStatValues = new Array()\n";
print "function Statistics(count, entry)\n";
print "{\n";
print "alert (count+entry)\n";
print "HorseStatValues[count] = entry\n";
print "alert (\"HorseStat = \"+HorseStatValues[count])\n";
print "return[false]\n";
print "}\n";
print "function Select(elemName, numElements)\n";
print "{\n";
print "var SelectedParameter =
document.getElementById(elemName).options[document.getElementById(elemName).selectedIndex].text\n";
print "alert (\"Params = \"+numElements+\"##Box =
\"+elemName+\"##Value = \"+SelectedParameter)\n";
print "SelectedParamArray[elemName] = SelectedParameter\n";
print "alert (\"Stored Array Value = \"+SelectedParamArray[3])\n";
print "}\n";
print "</SCRIPT></HEAD>\n";