Here's two ways* I would consider (there are pros and cons to each):
1. HTML and Javascript (fast, client-side, but 10%± have JS turned off):
First number: <input type="text" id="num1" /> Second number: <input type="text" id="num2" /> Your answer: <input type="text" id="answer" /> Add them: <input type="button" value="Add" onclick="addthem();" />
or HTML for CGI handling, change last lines to:
Your answer: <input type="text" id="answer" value="<tmpl_var answer>" /> <input type="submit" value="Add" />
Javascript:
function addthem() { var num1 = document.getElementById("num1"); var num2 = document.getElementById("num2"); var answer = num1 + num2; document.getElementById("answer").value = answer; }
2. CGI and HTML::Template (doesn't require JS, but does require a module and a round robin to the server):
*all code is untesteduse HTML::Template; use CGI; my $query = new CGI; my $num1 = $query->param('num1'); my $num2 = $query->param('num2'); my $template = HTML::Template -> new(filename => "addnumbers.tmpl"); $template->param( answer => $num1 + $num2 ) print "Content-type: text/html\n\n"; print $template->output();
In reply to Re: How to get data from a web page.
by bradcathey
in thread How to get data from a web page.
by munu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |