Mercurial > rlmcintyre
comparison BoosterPack/scripts/.svn/text-base/pjx_splitargs.pl.svn-base @ 0:0d795f02a8bb tip
initial committ. what was I thinking?
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 27 Sep 2010 16:57:26 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0d795f02a8bb |
---|---|
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 |