diff scripts/pjx_splitargs.pl @ 0:477258d09353 boosterpack

[svn r1] initial import
author robert
date Sun, 30 Aug 2009 02:19:26 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/pjx_splitargs.pl	Sun Aug 30 02:19:26 2009 -0400
     1.3 @@ -0,0 +1,54 @@
     1.4 +#!C:/strawberry/perl/bin/perl.exe
     1.5 +
     1.6 +# this is an example script of how you would use coderefs to define
     1.7 +# your CGI::Ajax functions, and the methods return multiple results to
     1.8 +# the page
     1.9 +#
    1.10 +# NB The CGI::Ajax object must come AFTER the coderefs are declared.
    1.11 +
    1.12 +use strict;
    1.13 +use CGI::Ajax;
    1.14 +use CGI;
    1.15 +
    1.16 +my $q = new CGI;
    1.17 +
    1.18 +my $divide = sub {
    1.19 +  my $a = shift;
    1.20 +  my $b = shift;
    1.21 +  return ($a / $b,"this is 2nd return value");
    1.22 +};
    1.23 +
    1.24 +my $Show_Form = sub {
    1.25 +  my $html = "";
    1.26 +  $html .= <<EOT;
    1.27 +<HTML>
    1.28 +<HEAD><title>CGI::Ajax Multiple Return Value Example</title>
    1.29 +<script>
    1.30 +  my_call = function(){
    1.31 +   document.getElementById('out1').value = arguments[0];
    1.32 +   document.getElementById('out2').value = arguments[1];
    1.33 +  }
    1.34 +</script>
    1.35 +</HEAD>
    1.36 +<BODY>
    1.37 +<form>
    1.38 +  Enter Number:
    1.39 +<input type="text" id="val1" size="6" value=2 onkeyup="divide(['val1','val2'], [my_call]);">
    1.40 +<input type='text' id='val2' size=6 value=34 onkeyup="divide(['val1','val2'],[my_call]);">
    1.41 +
    1.42 +<input type=text id="out1" value ="">
    1.43 +<input type=text id="out2" value ="">
    1.44 +
    1.45 +
    1.46 +</form>
    1.47 +</BODY>
    1.48 +</HTML>
    1.49 +EOT
    1.50 +
    1.51 +  return $html;
    1.52 +};
    1.53 +
    1.54 +my $pjx = CGI::Ajax->new('divide' => $divide);
    1.55 +$pjx->JSDEBUG(1);
    1.56 +$pjx->DEBUG(1);
    1.57 +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page