Instead of javascript, you could just put the buttons in separate <form> tags so they have different actions. (Why no javascript?)
<form action="prog1.cgi"> ... <input type="submit" value="View"> </form> <hr> <form action="prog2.cgi"> ... <input type="submit" value="Edit"> </form>

If you want to do it strictly on the backend, a couple thoughts come to mind. First is that the script you submit to simply looks at the button value and then does a redirect to the appropriate .cgi url (constructing a query string of course so values are preserved). Take a look at CGI, specificall the param() and redirect methods.

Second backend way (and probably better) is that you just have one cgi file, but it (depending on the button value) calls code from different files (different "include" files or modules). Take a look in the Tutorials section for basics on modules and Including files.
my $btn = $q->param('button'); if( $btn eq 'viewBtn' ){ ... }elsif( $btn eq 'editBtn' ){ ... }else{ ... }

In reply to Re: CGI and HTML form by davidrw
in thread CGI and HTML form by gube

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.