comparison scripts/pjx_splitargs.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 # this is an example script of how you would use coderefs to define
4 # your CGI::Ajax functions, and the methods return multiple results to
5 # the page
6 #
7 # NB The CGI::Ajax object must come AFTER the coderefs are declared.
8
9 use strict;
10 use CGI::Ajax;
11 use CGI;
12
13 my $q = new CGI;
14
15 my $divide = sub {
16 my $a = shift;
17 my $b = shift;
18 return ($a / $b,"this is 2nd return value");
19 };
20
21 my $Show_Form = sub {
22 my $html = "";
23 $html .= <<EOT;
24 <HTML>
25 <HEAD><title>CGI::Ajax Multiple Return Value Example</title>
26 <script>
27 my_call = function(){
28 document.getElementById('out1').value = arguments[0];
29 document.getElementById('out2').value = arguments[1];
30 }
31 </script>
32 </HEAD>
33 <BODY>
34 <form>
35 Enter Number:
36 <input type="text" id="val1" size="6" value=2 onkeyup="divide(['val1','val2'], [my_call]);">
37 <input type='text' id='val2' size=6 value=34 onkeyup="divide(['val1','val2'],[my_call]);">
38
39 <input type=text id="out1" value ="">
40 <input type=text id="out2" value ="">
41
42
43 </form>
44 </BODY>
45 </HTML>
46 EOT
47
48 return $html;
49 };
50
51 my $pjx = CGI::Ajax->new('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