I am very new to the following: Programming, Perl, CGI's and Javascript. Hence I have a very big problem on my hands!
I am trying to get the submit buttons on this page to display a confirm "are you sure?" when clicked but I cannot get the Javascript bit to work. If you comment it out then the page will run but as soon as I put it back in I get an internal server error.
Any ideas would be greatly appreciated.
Faye
Here's my CGI:
#!/app/perl5005/bin/perl
# Ensure that Perl can see the DBI module...
push (@INC, $ENV{'WORKFLOW_PATH'} . "/lib/site_perl"
use DBI;
use CGI;
require "CDA_CGI.pl";
$ENV{'ORACLE_HOME'} = "/app/oracle/product/client/8.1.7";
$ENV{'TNS_ADMIN'} = "/var/opt/oracle";
$q = new CGI;
$EnvironmentName = $q -> param ('EnvironmentName') or &CGIError ("'EnvironmentName' not defined."
$AttributeGroup = $q -> param ('AttributeGroup') or &CGIError ("'AttributeGroup' not defined."
{
local ($/) = undef;
open (HTMLFILE, "templates/db_env_deployments.html" or &CGIError ("Unable to open 'db_env_deployments.html': $!"
$HTML = <HTMLFILE>;
close (HTMLFILE);
$DBDetailsFile = "/home/fwimpenn/.dtl_details";
open (DB_DETAILS, $DBDetailsFile) or &CGIError ("Unable to open '$DBDetailsFile': $!"
$DETAIL_LINE = <DB_DETAILS>;
close (DB_DETAILS);
}
chomp ($DETAIL_LINE);
($CodeLoaderDB, $Username, $Password) = split (/\s+/, $DETAIL_LINE);
$dbh = DBI -> connect ("DBI:Oracle:$CodeLoaderDB", $Username, $Password) or &CGIError ("Unable to connect to Database: "
$DBAttributes = $dbh -> prepare ("
select key, value
from code_loader.environment_attr
where attribute_group_name = '$AttributeGroup'
and environment_name = '$EnvironmentName'
order by key" );
$DBAttributes -> execute ();
#$FORM_TEXT = "Content-type: text/html\n\n";
#$FORM_TEXT .= "<script LANGUAGE=\"JavaScript\">\n";
#$FORM_TEXT .= "<!--\n";
#$FORM_TEXT .= "//This function allows the user to have a 'confirm' message displayed\n";
#$FORM_TEXT .= "//before following the desired link.\n";
#$FORM_TEXT .= "function confirmSubmit(message)
#$FORM_TEXT .= "{\n";
#$FORM_TEXT .= "var agree = confirm(message)\n";
#$FORM_TEXT .= "if (agree)\n";
#$FORM_TEXT .= "return true\n";
#$FORM_TEXT .= "else\n";
#$FORM_TEXT .= "return false\n";
#$FORM_TEXT .= "}"
#$FORM_TEXT .= "</Script>\n";
#
#$FORM_TEXT .= "<FORM NAME=\"ModifyAttributes\" ACTION=\"/cgi-bin/maintain_environment_attribute.cgi\" onSubmit=\"return confirmSubmit('Are you sure you want to deploy this component?\">\n";
#$FORM_TEXT .= "<table border=\"1\" height=\"34\">\n";
while (@COLUMNS = $DBAttributes -> fetchrow ())
{
($Key, $Value )= @COLUMNS;
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"Key\" VALUE=\"$Key\">";
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"EnvironmentName\" VALUE=\"$EnvironmentName\">";
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"AttributeGroup\" VALUE=\"$AttributeGroup\">";
$FORM_TEXT .= "<td width=\"20%\"height=\"25\">$Key</td>\n";
$FORM_TEXT .= "<td width=\"50%\"height=\"25\"><input type=\"text\" name=\"Value\" size=\"30\" value=\"$Value\"></td>\n";
$FORM_TEXT .= "<td width=\"15%\"height=\"25\"><input type=\"submit\" size=\"50\" value=\" Modify \" name=\"Modify\"></td>\n";
$FORM_TEXT .= "<td width=\"15%\"height=\"25\"><input type=\"submit\" size=\"50\" value=\"Remove\" name=\"Remove\"></td>\n";
$FORM_TEXT .= "</form>\n";
$FORM_TEXT .= "</TR>\n";
}
$FORM_TEXT .= "</table>\n";
$dbh -> disconnect ();
$HTML =~ s/XXX001/$FORM_TEXT/g;
$HTML =~ s/XXX002/$EnvironmentName/g;
print $q -> header (),
$HTML;
I am trying to get the submit buttons on this page to display a confirm "are you sure?" when clicked but I cannot get the Javascript bit to work. If you comment it out then the page will run but as soon as I put it back in I get an internal server error.
Any ideas would be greatly appreciated.
Faye
Here's my CGI:
#!/app/perl5005/bin/perl
# Ensure that Perl can see the DBI module...
push (@INC, $ENV{'WORKFLOW_PATH'} . "/lib/site_perl"
use DBI;
use CGI;
require "CDA_CGI.pl";
$ENV{'ORACLE_HOME'} = "/app/oracle/product/client/8.1.7";
$ENV{'TNS_ADMIN'} = "/var/opt/oracle";
$q = new CGI;
$EnvironmentName = $q -> param ('EnvironmentName') or &CGIError ("'EnvironmentName' not defined."
$AttributeGroup = $q -> param ('AttributeGroup') or &CGIError ("'AttributeGroup' not defined."
{
local ($/) = undef;
open (HTMLFILE, "templates/db_env_deployments.html" or &CGIError ("Unable to open 'db_env_deployments.html': $!"
$HTML = <HTMLFILE>;
close (HTMLFILE);
$DBDetailsFile = "/home/fwimpenn/.dtl_details";
open (DB_DETAILS, $DBDetailsFile) or &CGIError ("Unable to open '$DBDetailsFile': $!"
$DETAIL_LINE = <DB_DETAILS>;
close (DB_DETAILS);
}
chomp ($DETAIL_LINE);
($CodeLoaderDB, $Username, $Password) = split (/\s+/, $DETAIL_LINE);
$dbh = DBI -> connect ("DBI:Oracle:$CodeLoaderDB", $Username, $Password) or &CGIError ("Unable to connect to Database: "
$DBAttributes = $dbh -> prepare ("
select key, value
from code_loader.environment_attr
where attribute_group_name = '$AttributeGroup'
and environment_name = '$EnvironmentName'
order by key" );
$DBAttributes -> execute ();
#$FORM_TEXT = "Content-type: text/html\n\n";
#$FORM_TEXT .= "<script LANGUAGE=\"JavaScript\">\n";
#$FORM_TEXT .= "<!--\n";
#$FORM_TEXT .= "//This function allows the user to have a 'confirm' message displayed\n";
#$FORM_TEXT .= "//before following the desired link.\n";
#$FORM_TEXT .= "function confirmSubmit(message)
#$FORM_TEXT .= "{\n";
#$FORM_TEXT .= "var agree = confirm(message)\n";
#$FORM_TEXT .= "if (agree)\n";
#$FORM_TEXT .= "return true\n";
#$FORM_TEXT .= "else\n";
#$FORM_TEXT .= "return false\n";
#$FORM_TEXT .= "}"
#$FORM_TEXT .= "</Script>\n";
#
#$FORM_TEXT .= "<FORM NAME=\"ModifyAttributes\" ACTION=\"/cgi-bin/maintain_environment_attribute.cgi\" onSubmit=\"return confirmSubmit('Are you sure you want to deploy this component?\">\n";
#$FORM_TEXT .= "<table border=\"1\" height=\"34\">\n";
while (@COLUMNS = $DBAttributes -> fetchrow ())
{
($Key, $Value )= @COLUMNS;
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"Key\" VALUE=\"$Key\">";
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"EnvironmentName\" VALUE=\"$EnvironmentName\">";
$FORM_TEXT .= "<INPUT TYPE=\"HIDDEN\" NAME=\"AttributeGroup\" VALUE=\"$AttributeGroup\">";
$FORM_TEXT .= "<td width=\"20%\"height=\"25\">$Key</td>\n";
$FORM_TEXT .= "<td width=\"50%\"height=\"25\"><input type=\"text\" name=\"Value\" size=\"30\" value=\"$Value\"></td>\n";
$FORM_TEXT .= "<td width=\"15%\"height=\"25\"><input type=\"submit\" size=\"50\" value=\" Modify \" name=\"Modify\"></td>\n";
$FORM_TEXT .= "<td width=\"15%\"height=\"25\"><input type=\"submit\" size=\"50\" value=\"Remove\" name=\"Remove\"></td>\n";
$FORM_TEXT .= "</form>\n";
$FORM_TEXT .= "</TR>\n";
}
$FORM_TEXT .= "</table>\n";
$dbh -> disconnect ();
$HTML =~ s/XXX001/$FORM_TEXT/g;
$HTML =~ s/XXX002/$EnvironmentName/g;
print $q -> header (),
$HTML;