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

Green horn here, I have a perl cgi script that, before my start_form, I decide if I want to give the user a check_box group and a continue button, or a have them continue along to the next cgi script.
if ($wantSar){ print $query->h3("Please select the sar options you would like to +anayze or plot for $client:"), $query->start_form(-action => "firedates.cgi", -enctype => "application/x-www-form-urlenco +ded", -method => "post"), $query->p, $query->checkbox_group(-name=>'avmetrics', -values=> [ sort keys %metaAndOptions + ], -labels=> \%metaAndOptions, -columns=> 1), $query->p, $query->submit(-name=>'Continue'), $query->reset(-name=>'Clear'), $query->hr; } else { #They don't want sar options, so bring them to the dates sc +reen print $query->start_form(-action => "firedates.cgi", -enctype => "application/x-www-form-urlenco +ded", -method => "post"); } }
I have an end routine that runs right after this, which in part creates some hidden variables that can be passed on to the next script, and it also produces the end_html code.

My question is, how do I get the else part to execute and continue along to the next page (after the end routine, of course)

Also, along with a continue and clear button, how do I write a select all button? Does such a creature exist? thanks GR8 11

Replies are listed 'Best First'.
Re: form method in a null form
by sasikumar (Monk) on Jan 19, 2005 at 07:06 UTC
    Hi

    how do I get the else part to execute and continue along to the next page

    Use java script to do the job. Just redirct it to a new page using the java script. Put this script in the else part.

    how do I write a select all button

    So it with the help of onclick jscript function.

    Thanks
    SasiKumar
      As was pointed out in a response to a recent post I made, you have to be aware that either
      • you have control over the clients running the script to ensure that the local scripting language is always running,
        or,
      • you need to take into account that users can modify the client config to disable scripting locally and/or muck around with your form to send invalid data

      As an aside, you may want to consider skipping the form entirely for the "else" condition. Procedurally, I can understand the logic in having all users flowing through the same pages/forms, however, you obviously have all the data needed to skip the form entirely and send them to the next stage.

Re: form method in a null form
by dorward (Curate) on Jan 19, 2005 at 16:57 UTC

    If you don't want to display the form, but direct the user to another script entirely, then you should output a 302 HTTP status code and a suitable Location header thus having them bypass (from their point of view) the page entirely. The drawback to this approach is that it adds a little to the complexity of getting any unchanging form data (that you would normally put in a hidden input) to the next script in the sequence.

    If you have only a little data, you could encode it as a query string on the URI. This has the drawback of being bookmarkable and easily refreshable - which could have drawbacks if the submission changes anything on the server. (I'm assuming it will since you are using the post method in the first place).

    If you have more data, or for a bit more safety, you could store the data somewhere on the server (a database or flat file) with a unique identifier, then include that identifier in the query string. (And have sensible clean up routines).