P
pleaseexplaintome
Hi I have the following perl/cgi script snippet. The goal of this
script is to pass a javascript variable to perl where it can be re-used
later. Any help is appreciated, Thanks
#!/ois/usr/bin/perl -w
use strict;
use CGI qwstandard);
my $cgi=new CGI;
my $flg=0;
my $datatosave="";
starthtml();
exit 0;
############################################################################################################
sub starthtml {
print "Content-Type: text/html\n\n" ;
print qq(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN") ;
print qq( "http://www.w3.org/TR/html4/Transitional.dtd"> ) ;
print qq(<html>) ;
print qq(<head>) ;
print qq(<title></title>) ;
print qq(<script language="javascript" type="text/javascript"> ) ;
print qq(function get_textarea() { ) ;
# ALERT DISPLAYS AS EXPECTED
print qq( alert(document.form1.mytextarea.value);
# JAVASCRIPT ERROR OCCURS HERE
# $datatosave = $cgi->param('mytextarea');
# ALERT DOES NOT DISPLAY AS EXPECTED
# print qq( alert($datatosave);
# ALERT DOES NOT DISPLAY AS EXPECTED
# JAVASCRIPT ERROR OCCURS HERE
print qq( alert($cgi->param('mytextarea'));
print qq(} ) ;
print qq(</script> ) ;
print qq(</head><body bgcolor="#FFFFCC">) ;
print qq(<form name=form1 method="post" action="path to test.cgi">)
;
# SUBMIT BUTTON BECAUSE IT WILL ULTIMATELY BE USED TO DISPLAY A
FILE'S CONTENTS
# print qq(<input type="submit" value="Show File">);
# TRIED BOTH SUBMIT AND BUTTON TYPES HERE
print qq(<input type="submit" value="Populate Variable"
onclick="get_textarea()">);
# THE TEXTAREA TO COPY INTO A PERL VARIABLE
print $cgi->textarea(-name=>'mytextarea',
-default=>'test data',
-rows=>5,
-columns=>20);
print qq(</form>) ."\n";
print qq(</body></html>) ;
}
script is to pass a javascript variable to perl where it can be re-used
later. Any help is appreciated, Thanks
#!/ois/usr/bin/perl -w
use strict;
use CGI qwstandard);
my $cgi=new CGI;
my $flg=0;
my $datatosave="";
starthtml();
exit 0;
############################################################################################################
sub starthtml {
print "Content-Type: text/html\n\n" ;
print qq(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN") ;
print qq( "http://www.w3.org/TR/html4/Transitional.dtd"> ) ;
print qq(<html>) ;
print qq(<head>) ;
print qq(<title></title>) ;
print qq(<script language="javascript" type="text/javascript"> ) ;
print qq(function get_textarea() { ) ;
# ALERT DISPLAYS AS EXPECTED
print qq( alert(document.form1.mytextarea.value);
# JAVASCRIPT ERROR OCCURS HERE
# $datatosave = $cgi->param('mytextarea');
# ALERT DOES NOT DISPLAY AS EXPECTED
# print qq( alert($datatosave);
# ALERT DOES NOT DISPLAY AS EXPECTED
# JAVASCRIPT ERROR OCCURS HERE
print qq( alert($cgi->param('mytextarea'));
print qq(} ) ;
print qq(</script> ) ;
print qq(</head><body bgcolor="#FFFFCC">) ;
print qq(<form name=form1 method="post" action="path to test.cgi">)
;
# SUBMIT BUTTON BECAUSE IT WILL ULTIMATELY BE USED TO DISPLAY A
FILE'S CONTENTS
# print qq(<input type="submit" value="Show File">);
# TRIED BOTH SUBMIT AND BUTTON TYPES HERE
print qq(<input type="submit" value="Populate Variable"
onclick="get_textarea()">);
# THE TEXTAREA TO COPY INTO A PERL VARIABLE
print $cgi->textarea(-name=>'mytextarea',
-default=>'test data',
-rows=>5,
-columns=>20);
print qq(</form>) ."\n";
print qq(</body></html>) ;
}