Mercurial > boosterpack
view scripts/pjx_chained.pl @ 0:477258d09353 boosterpack
[svn r1] initial import
author | robert |
---|---|
date | Sun, 30 Aug 2009 02:19:26 -0400 |
parents | |
children |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe3 # pjx_chained.pl: Multiple exported perl subs, and the exported4 # functions are chained to an event, like this...5 # onclick="func1(['in1'],['out1']); func2(['in1'],['out2']);"7 use strict;8 use CGI::Ajax;9 use CGI;11 my $q = new CGI;13 my $multiply = sub {14 my $a = shift;15 my $b = shift;16 return $a * $b;17 };19 my $divide = sub {20 my $a = shift;21 my $b = shift;22 return $a / $b;23 };25 my $Show_Form = sub {26 my $html = "";27 $html .= <<EOT;28 <HTML>29 <HEAD><title>CGI::Ajax Chained function Example</title>30 </HEAD>31 <BODY>32 <form>33 Enter Number:34 <input type="text" id="val1" size="6" value=235 onkeyup="divide(['val1','val2'], ['out1']); multiply(['val1','val2'], ['out2']);">37 <input type="text" id="val2" size="6" value = 738 onkeyup="divide(['val1','val2'], ['out1']); multiply(['val1','val2'], ['out2']);"><br/><br/>40 <input type=text id="out1">41 <input type=text id="out2">44 </form>45 </BODY>46 </HTML>47 EOT48 return $html;49 };51 my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide);52 $pjx->JSDEBUG(1);53 $pjx->DEBUG(1);54 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page