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

I have a script that generates a page with several user input fields on it as well as three buttons. One button redirects the user to a html page the second button will need to call a perl script and the last button needs to refresh changes made by the user. Can someone suggest the best way to approach this? Thanks - Tom

Replies are listed 'Best First'.
Re: Multi process
by TomK32 (Monk) on Dec 01, 2001 at 14:37 UTC
    WildThing did a nice comment, but he not only mixed refresh with reset but also the redirect can be done better.
    #!/usr/bin/perl use CGI qw(:standard); if (param('othersite')) { redirect('http://www.tomk32.de'); } elsif (param('script')) { print param('data'); #or do some magic } else { print start_html(), start_form(), textfield('data', $data), submit('script'), submit('refresh'), submit('othersite'), end_form +, end_html(); }
    -- package Lizard::King; sub can { do { 'anything'} };
Re: Multi process
by Dogma (Pilgrim) on Dec 01, 2001 at 15:16 UTC
    This is mostly a matter of personal style but I find that maintainability is almost always more important then performance. I would do everything as a single cgi that generates the inital form and even returns a redirect for your one static page. (see example above) It's usualy alot easier to have do deal with only one file for simple stuff. In my mind it's also much better self documenting because you can see the pieces in one place. I would highly rec-o-mend the book cgi programming with perl.
Re: Multi process
by WildThing (Initiate) on Dec 01, 2001 at 13:56 UTC
    I'm presuming that your third button needs to "refresh" the settings that were on the page by default.
    Secondly, I'll presume that even though your a Windose pregrammer you want cross-browser functionality and need to support versions 4.x and up.

    • Insert a javascript function in the first button's HTML tag - example < INPUT TYPE='BUTTON' NAME='REDIRECT' onClick='window.location=http:www.somedomain.com/someurl'>
    • Use that standard SUBMIT input type for the CGI call
    • Use the standard RESET input type for the refresh


    If that's not what you were explaining let me know and I'll try to help.

    Why didn't I take the Blue Pill