diff scripts/pjx_cr.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_cr.pl	Sun Aug 30 02:19:26 2009 -0400
     1.3 @@ -0,0 +1,57 @@
     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.
     1.8 +#
     1.9 +# NB The CGI::Ajax object must come AFTER the coderefs are declared.
    1.10 +
    1.11 +use strict;
    1.12 +use CGI::Ajax;
    1.13 +use CGI;
    1.14 +
    1.15 +my $q = new CGI;
    1.16 +
    1.17 +my $exported_fx = sub {
    1.18 +  my $value_a = shift;
    1.19 +  my $value_b = shift;
    1.20 +  $value_a = "" if not defined $value_a; # make sure there's def
    1.21 +  $value_b = "" if not defined $value_b; # make sure there's def
    1.22 +
    1.23 +  if ( $value_a =~ /\D+/ or $value_a eq "" ) {
    1.24 +    return( $value_a . " and " . $value_b );
    1.25 +  } elsif ( $value_b =~ /\D+/ or $value_b eq "" ) {
    1.26 +    return( $value_a . " and " . $value_b );
    1.27 +  } else {
    1.28 +    # got two numbers, so lets multiply them together
    1.29 +    return( $value_a * $value_b );
    1.30 +  }
    1.31 +};
    1.32 +
    1.33 +
    1.34 +my $Show_Form = sub {
    1.35 +  my $html = "";
    1.36 +  $html .= <<EOT;
    1.37 +<HTML>
    1.38 +<HEAD><title>CGI::Ajax Example</title>
    1.39 +</HEAD>
    1.40 +<BODY>
    1.41 +<form>
    1.42 +  Enter something:&nbsp;
    1.43 +  <input type="text" name="val1" id="val1" size="6" onkeyup="myfunc( ['val1','val2'], ['resultdiv'] ); return true;"><br>
    1.44 +
    1.45 +  Enter something else:&nbsp;
    1.46 +  <input type="text" name="val2" id="val2" size="6" onkeyup="myfunc( ['val1','val2'], ['resultdiv'] ); return true;"><br>
    1.47 +
    1.48 +    <hr>
    1.49 +    <div id="resultdiv" style="border: 1px solid black; width: 440px; height: 80px; overflow: auto">
    1.50 +    </div>
    1.51 +</form>
    1.52 +</BODY>
    1.53 +</HTML>
    1.54 +EOT
    1.55 +
    1.56 +  return $html;
    1.57 +};
    1.58 +
    1.59 +my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx);
    1.60 +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page