Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI.pm: Opening new browser window

Status
Not open for further replies.

aswolff

Programmer
Jul 31, 2006
100
US
Hello,

I have a CGI script which displays a form. When form is submitted it runs a command on the server which outputs a complete html document including <HTML>,<HEAD>, <BODY> tags.

After the command runs and the HTML document is created I want my cgi script to take the output and display it a new browser window.

Is this possible using CGI.pm? Any tips or sample code is appreciated.

My original concept was to take the newly created html document and display it below my form..but since I am already within a 'q->start_html' section....then it would conflict with a new set of <HTML> tags embedded in the document.

Here is my Code:

Code:
use CGI;

my $q = new CGI;
my $url = $q->url();
my @names = $q->param;
my $which_one = 'none';
my $len = @names;
my $syscode = 'none';
my $tbl = 'none';

print $q->header(-type=>'text/html'),

$q->start_html(-title=>'Lawson Applications DB Doc Web Client'),
$q->start_form(-method=>'POST',-action=>'mytest_b.exe'),
$q->start_table({-border=>1,-align=>CENTER,-bordercolor=>'0099CC',-bgcolor=>'FFFFFF'}),

$q->Tr({-align=>LEFT,-valign=>TOP}),
$q->start_td, $q->h3("System Code:"),$q->end_td,
$q->start_td, $q->textfield(-name=>'syscode',-size=>'3',-maxlength=>'2'),$q->end_td,

$q->Tr({-align=>CENTER,-valign=>TOP}),
$q->start_td, $q->h3("Table Name:"),$q->end_td,
$q->start_td, $q->textfield(-name=>'tblname',-size=>'11',-maxlength=>'10'),$q->end_td,

$q->Tr({-align=>CENTER,-valign=>TOP}),
$q->start_td, $q->submit({-name=>'btnReset',-label=>'Reset'}),$q->end_td,
$q->start_td, $q->submit({-name=>'btnSubmit',-label=>'Submit'}),$q->end_td,

$q->end_table(),
$q->end_form();

$which_one = $q->param('btnSubmit');

if ($which_one eq 'Submit') 
{
	$syscode = $q->param('syscode');
	$tbl = $q->param('tblname');
	@url = split(/\//,$q->url(-absolute=>1));
	$pl = $url[2];
	$command = 'dbdoc ' . "$pl $syscode $tbl";

	$out = `$command 2>/dev/null`;

	print $q->h5($out);  ##I want the new html output to be displayed in a new browser window
	print $q->h5($command);
	
}
else 
{
    $q->delete_all();
}
print $q->end_html;
exit (0);

 
My original concept was to take the newly created html document and display it below my form..but since I am already within a 'q->start_html' section....then it would conflict with a new set of <HTML> tags embedded in the document.

No It wouldn't. Just check for any condition that alerts you that the form was submitted and throw in an "if" condition where you want to print the data within the code you posted above.

For example:

Code:
$q->end_table(),
if (condition) {
  print some data here with any html tags you want
}
$q->end_form();



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top