Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,
dws was nice enough to post the following sample that I've tried to modify. I'm learning some of the basics of CGI and Frames so I was trying to update the left pane with a simple message after clicking the submit button. Nothing seems to happen when I do so. Do I have to specify the target for my submit as it self (i.e. -target="_self")?
#!/usr/bin/perl use strict; use CGI qw(:standard); my $query = new CGI; if (param('USE')) {print header; print 'Updating the LEFT Frame'; } print header(); if ( defined $query->param('left') ) { print start_html(); print $query -> submit({-name=>'USE'}); print h1("Left"); print end_html(); } elsif ( defined $query->param('right') ) { print start_html(); print h1("Right"); print end_html(); } else { my $script = $ENV{'SCRIPT_NAME'}; print frameset( {-cols => "25%,75%"}, frame({-name => "left", -src => "$script?left=1"}), frame({-name => "right", -src => "$script?right=1"}) ); }
Any thoughts?

Replies are listed 'Best First'.
Re: CGI Frames, and submit
by eric256 (Parson) on Oct 19, 2004 at 13:46 UTC

    If you take a peek at the HTML that produces you will see that its not creating the form. Its only creating the submit element. Check CGI Docs to see how to start and end forms. You can use the -target attribute of forms to control which frame it submits too.


    ___________
    Eric Hodges
Re: CGI Frames, and submit
by muntfish (Chaplain) on Oct 19, 2004 at 13:49 UTC

    Your submit button needs to be within an HTML <form> tag, which tells the browser what URL to send the query to. At the moment, the browser would have no idea what to do when you press Submit. By default the result would appear in the same frame that the query was submitted from, but you can change that with the target attribute of the <form>.

    Have a look at the CGI docs for how to write a <form> tag using the CGI.pm methods.


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&