So I have the following html script, and perl cgi script for a basic calculator for Apache. What I was wondering was if it is possible to add a button to the output from the cgi script, that links back to the original html file? Basically a button to start over again after the script gives you the answer. Any tips?
HTML
<html> <head> <title>Simple Calculator</title> </head> <body> <h1> Simple Calculator </h1> <form action=/cgi-bin/calc.pl method=post> <center> First Number: <input type=text name=na maxlength=4 size=4><p> Second Number (or Exponent Number): <input type=text name=nb maxlength +=4 size=4><p> Preferred mathematical operation:<br> <input type="radio" name=oper value="mul">Multiply<br> <input type="radio" name=oper value="div">Divide<br> <input type="radio" name=oper value="add">Addition<br> <input type="radio" name=oper value="sub">Subtraction<br> <input type="radio" name=oper value="expo">Exponent<br> <p> <input type="submit" value="Submit form"> <input type="reset" value-"Clear all fields"> </form> </body> </html>
Perl CGI:
#!/usr/bin/perl -w use CGI ':standard'; $na = param('na'); $nb = param('nb'); $oper = param('oper'); if ($oper eq "mul") { $answ = $na * $nb; } elsif($oper eq "div") { $answ = $na / $nb; } elsif($oper eq "add") { $answ = $na + $nb; } elsif($oper eq "sub") { $answ = $na - $nb; $nd = "-"; } else {$answ = $na ** $nb; } print "Content-type:text/html\r\n\r\n"; print "<html>"; print "<head>"; print "<title> Answer Page</title>"; print "</head>"; print "<body>"; print "<H2> The answer to your calculation is: $answ </H2>"; + print "</body>"; print "</html>";
In reply to Not sure if possible? by mwerner92
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |