Mercurial > boosterpack
comparison scripts/pjx_chained.pl @ 0:477258d09353 boosterpack
[svn r1] initial import
author | robert |
---|---|
date | Sun, 30 Aug 2009 02:19:26 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:477258d09353 |
---|---|
1 #!C:/strawberry/perl/bin/perl.exe | |
2 | |
3 # pjx_chained.pl: Multiple exported perl subs, and the exported | |
4 # functions are chained to an event, like this... | |
5 # onclick="func1(['in1'],['out1']); func2(['in1'],['out2']);" | |
6 | |
7 use strict; | |
8 use CGI::Ajax; | |
9 use CGI; | |
10 | |
11 my $q = new CGI; | |
12 | |
13 my $multiply = sub { | |
14 my $a = shift; | |
15 my $b = shift; | |
16 return $a * $b; | |
17 }; | |
18 | |
19 my $divide = sub { | |
20 my $a = shift; | |
21 my $b = shift; | |
22 return $a / $b; | |
23 }; | |
24 | |
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=2 | |
35 onkeyup="divide(['val1','val2'], ['out1']); multiply(['val1','val2'], ['out2']);"> | |
36 | |
37 <input type="text" id="val2" size="6" value = 7 | |
38 onkeyup="divide(['val1','val2'], ['out1']); multiply(['val1','val2'], ['out2']);"><br/><br/> | |
39 | |
40 <input type=text id="out1"> | |
41 <input type=text id="out2"> | |
42 | |
43 | |
44 </form> | |
45 </BODY> | |
46 </HTML> | |
47 EOT | |
48 return $html; | |
49 }; | |
50 | |
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 |