Mercurial > boosterpack
diff scripts/pjx_objects_2_url.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_objects_2_url.pl Sun Aug 30 02:19:26 2009 -0400 1.3 @@ -0,0 +1,59 @@ 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 $iq = new CGI; 1.20 + my $a = $q->param('a'); 1.21 + my $b = $q->param('b'); 1.22 + my $test = $q->param('test'); 1.23 + return( 1.24 + 'entered value was: ' . $value_a . 1.25 + '<br/>a was: ' . $a . "..." . 1.26 + '<br/>b was: ' . $b . "..." . 1.27 + '<br/>test was: ' . $test . "..." 1.28 + ); 1.29 +}; 1.30 + 1.31 + 1.32 +my $Show_Form = sub { 1.33 + my $html = ""; 1.34 + $html .= <<EOT; 1.35 +<HTML> 1.36 +<HEAD><title>CGI::Ajax Example</title> 1.37 +</HEAD> 1.38 +<BODY> 1.39 +<form> 1.40 +this javascript object is sent in as an argument: 1.41 +{'a':123,'b':345,'test':'123 Evergreen Terrace'} 1.42 +<br/><br/> 1.43 + Enter something else: 1.44 + <input type="text" name="val1" size="6" onkeyup="myfunc( 1.45 + ['val1',{'a':123,'b':345,'test':'123 Evergreen Terrace'} ], 'resultdiv' ); return true;"><br> 1.46 + 1.47 + <hr> 1.48 + <DIV id="resultdiv" style="border: 1px solid black; width: 440px; height: 80px; overflow: auto"> 1.49 + </div> 1.50 +</form> 1.51 +</BODY> 1.52 +</HTML> 1.53 +EOT 1.54 + 1.55 + return $html; 1.56 +}; 1.57 + 1.58 +my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx); 1.59 +$pjx->JSDEBUG(2); 1.60 +$pjx->DEBUG(2); 1.61 +print $pjx->build_html($q,$Show_Form); # this outputs the html for the page 1.62 +