Mercurial > rlmcintyre
view 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 |
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 $divide = sub {16 my $a = shift;17 my $b = shift;18 return ($a / $b,"this is 2nd return value");19 };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]);">39 <input type=text id="out1" value ="">40 <input type=text id="out2" value ="">43 </form>44 </BODY>45 </HTML>46 EOT48 return $html;49 };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