From: [email protected]
[mailto:[email protected]] On Behalf Of
Kprasad
Sent: 06 October 2009 15:15
To: [email protected]
Subject: Using .cgi file as form action

> Hi
>  
> I'm using HTML form to execute a .cgi script and I want the output of
cgi script should display in the same 
> window in which Form is displayed.
>  
> Anyone can suggest that how to do it.

I would have thought that the simplest way would be for the cgi program
to output both the form, and when data is entered on the form, the
output as well.

This isn't really a Perl question, but as this is a Perl forum here is a
simplistic example of what I mean.

------------------------------------------------------
use strict;
use warnings;

use CGI::Pretty qw{:standard *form *select};
use CGI::Carp qw{fatalsToBrowser};

my @options = ("This", "That", "The other");

my $sel = param("selection") || "";

print header;
print start_html("Simple form");
output_form();
output_data() if $sel ne "";
print end_html;

sub output_form {
    print h1("This is a form");
    print start_form({method => "post", action=>"simple_form.pl"});
    print strong("Select something: ");
    print Select({name => "selection"},
                 map {option($_ eq $sel ? {selected => 1} : {}, $_)}
@options);
    print p();
    print submit("Use that");
    print end_form;
    print hr();
}

sub output_data {
    print h2("You selected something");
    print "It was ", strong($sel);
}
------------------------------------------------------

HTH

-- 
Brian Raven 
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to