in reply to eval question
Check out this smooth Perl/Ajax/Google Calculator achieved by adding 3 measly lines to a script that Perlmonk varian posted here 2 days ago:
#!/usr/bin/perl -w use strict; use CGI::Ajax; use CGI qw(:all); use WWW::Google::Calculator; my $cgi = CGI->new; my $pjx = CGI::Ajax->new('submitted_formdata' => \&process_formdata); print $pjx->build_html($cgi,\&show_some_html); sub show_some_html { return <<'END_HTML'; <html> <head><title>Google Calculator</title></head> <body><form method="POST"> <b><a href=http://www.google.com/help/calculator.html title="How to use the Google calculator">Google</a></b> <input type="text" name="surname" id="surname"> <input type="button" onClick= "submitted_formdata( ['surname'],['response1'],'POST');" value="Calculate"> </form> <div id="response1" name="response1"></div> </body> </html> END_HTML } sub process_formdata { my $surname = shift; my $calc = WWW::Google::Calculator->new; return $calc->calc($surname) || 'ERROR ' . $calc->error; }
|
|---|