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\p erl
use CGI qw(:standard);
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>PRO JECT ONE</TITLE>";
print "<SCRIPT LANGUAGE = \"JavaScript\"> ";
var SelectedParamAr ray = new Array();
var HorseStatValues = new Array();
function Statistics(coun t, entry)
{
alert (count+entry);
HorseStatValues[count] = entry;
alert (\"HorseStat = \"+HorseStatVal ues[count]);
return[false];
}
function Select(elemName , numElements)
{
var SelectedParamet er =
document.getEle mentById(elemNa me).options[document.getEle mentById(elemNa me).selectedInd ex].text;
alert ("Params = "+numElements+" ##Box = "+elemName+"##V alue =
"+SelectedParam eter);
SelectedParamAr ray[elemName] = SelectedParamet er;
alert ("Stored Array Value = "+SelectedParam Array[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><f ont color=\"#FFFFFF \">HORSE
STATISTICS</font></p>";
print "<p align=center><s elect name =\"stats\" size=\"5\">";
$entrycount = 1;
open(RD,"C:\\Pr ogram Files\\Apache
Group\\Apache2\ \htdocs\\horse. txt");
while ($stats = <RD>)
{
$total = 0;
@stats = split(",", $stats);
$TotalStats = $#stats;
for ($length=1; $length<=$#stat s; $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><f ont color=\"#FFFFFF \">KEY</font></p>";
print "<p align=center><s elect name = \"key\" size=\"5\">";
$paramcount = 1;
open(MT,"C:\\Pr ogram 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><f ont color=\"#FFFFFF \">PARAMETER S</font></p>";
print "<br>";
$int = 0;
$test = 1;
@values = (1,2,3,4,5,7,8, 9,10);
for ($length2=1; $length2<=$Tota lStats; $length2++) {
print "<font color=\"#FFFFFF \"> $test> </font>";
print "<select name = $test size=\"5\" onclick = Select('$test',
'$TotalStats')> ";
for ($length=0; $length<=$#valu es; $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 SelectedParamAr ray = new Array()\n";
print "var HorseStatValues = new Array()\n";
print "function Statistics(coun t, entry)\n";
print "{\n";
print "alert (count+entry)\n ";
print "HorseStatValue s[count] = entry\n";
print "alert (\"HorseStat = \"+HorseStatVal ues[count])\n";
print "return[false]\n";
print "}\n";
print "function Select(elemName , numElements)\n" ;
print "{\n";
print "var SelectedParamet er =
document.getEle mentById(elemNa me).options[document.getEle mentById(elemNa me).selectedInd ex].text\n";
print "alert (\"Params = \"+numElements+ \"##Box =
\"+elemName+\"# #Value = \"+SelectedPara meter)\n";
print "SelectedParamA rray[elemName] = SelectedParamet er\n";
print "alert (\"Stored Array Value = \"+SelectedPara mArray[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\p erl
use CGI qw(:standard);
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD>";
print "<TITLE>PRO JECT ONE</TITLE>";
print "<SCRIPT LANGUAGE = \"JavaScript\"> ";
var SelectedParamAr ray = new Array();
var HorseStatValues = new Array();
function Statistics(coun t, entry)
{
alert (count+entry);
HorseStatValues[count] = entry;
alert (\"HorseStat = \"+HorseStatVal ues[count]);
return[false];
}
function Select(elemName , numElements)
{
var SelectedParamet er =
document.getEle mentById(elemNa me).options[document.getEle mentById(elemNa me).selectedInd ex].text;
alert ("Params = "+numElements+" ##Box = "+elemName+"##V alue =
"+SelectedParam eter);
SelectedParamAr ray[elemName] = SelectedParamet er;
alert ("Stored Array Value = "+SelectedParam Array[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><f ont color=\"#FFFFFF \">HORSE
STATISTICS</font></p>";
print "<p align=center><s elect name =\"stats\" size=\"5\">";
$entrycount = 1;
open(RD,"C:\\Pr ogram Files\\Apache
Group\\Apache2\ \htdocs\\horse. txt");
while ($stats = <RD>)
{
$total = 0;
@stats = split(",", $stats);
$TotalStats = $#stats;
for ($length=1; $length<=$#stat s; $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><f ont color=\"#FFFFFF \">KEY</font></p>";
print "<p align=center><s elect name = \"key\" size=\"5\">";
$paramcount = 1;
open(MT,"C:\\Pr ogram 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><f ont color=\"#FFFFFF \">PARAMETER S</font></p>";
print "<br>";
$int = 0;
$test = 1;
@values = (1,2,3,4,5,7,8, 9,10);
for ($length2=1; $length2<=$Tota lStats; $length2++) {
print "<font color=\"#FFFFFF \"> $test> </font>";
print "<select name = $test size=\"5\" onclick = Select('$test',
'$TotalStats')> ";
for ($length=0; $length<=$#valu es; $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 SelectedParamAr ray = new Array()\n";
print "var HorseStatValues = new Array()\n";
print "function Statistics(coun t, entry)\n";
print "{\n";
print "alert (count+entry)\n ";
print "HorseStatValue s[count] = entry\n";
print "alert (\"HorseStat = \"+HorseStatVal ues[count])\n";
print "return[false]\n";
print "}\n";
print "function Select(elemName , numElements)\n" ;
print "{\n";
print "var SelectedParamet er =
document.getEle mentById(elemNa me).options[document.getEle mentById(elemNa me).selectedInd ex].text\n";
print "alert (\"Params = \"+numElements+ \"##Box =
\"+elemName+\"# #Value = \"+SelectedPara meter)\n";
print "SelectedParamA rray[elemName] = SelectedParamet er\n";
print "alert (\"Stored Array Value = \"+SelectedPara mArray[3])\n";
print "}\n";
print "</SCRIPT></HEAD>\n";
Comment