Mercurial > boosterpack
view scripts/pjx_callback.pl @ 6:4246c7ef6487 boosterpack
[svn r8] bug fix -- holos need to be one int three compared to rares
author | robert |
---|---|
date | Tue, 08 Sep 2009 17:20:52 -0400 |
parents | 477258d09353 |
children |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe3 # this is an example script of how you would use coderefs to define4 # your CGI::Ajax functions, and the methods return multiple results to5 # the page6 #7 # NB The CGI::Ajax object must come AFTER the coderefs are declared.9 use strict;10 use CGI::Ajax;11 use CGI;13 my $q = new CGI;15 my $multiply = sub {16 my $a = shift;17 my $b = shift;18 return $a * $b;19 };21 my $divide = sub {22 my $a = shift;23 my $b = shift;24 return $a / $b;25 };26 my $G = 'asdf';27 my $Show_Form = sub {28 my $html = "";29 $html .= qq!30 <HTML>31 <HEAD><title>CGI::Ajax Multiple Return Value Example</title>32 <script>33 my_call = function(){34 document.getElementById('out1').value = arguments[0];35 call_2();36 document.getElementById('out3').innerHTML = this.url;37 }38 call_2 =function(){39 multiply(['val1','val2'],['out2'],'POST');40 }42 </script>43 </HEAD>44 <BODY>45 <form>46 Enter Number:47 <input type="text" id="val1" size="6" value=248 onkeyup="divide(['val1','val2','args__$G'], [my_call], 'POST');">49 <input type='text' id='val2' size=6 value=34>51 <input type=text id="out1">52 <input type=text id="out2"><br/>53 URL FROM "this" in callback:<div id="out3"> </div>56 </form>57 </BODY>58 </HTML>59 !;61 return $html;62 };65 my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide);66 $pjx->JSDEBUG(1);67 $pjx->DEBUG(1);68 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page