annotate scripts/pjx_objects_2_url.pl @ 2:d7dd496a4fa6 boosterpack

[svn r4] actual functionality!
author robert
date Tue, 08 Sep 2009 02:45:26 -0400
parents 477258d09353
children
rev   line source
robert@0 1 #!C:/strawberry/perl/bin/perl.exe
robert@0 2
robert@0 3 # this is an example script of how you would use coderefs to define
robert@0 4 # your CGI::Ajax functions.
robert@0 5 #
robert@0 6 # NB The CGI::Ajax object must come AFTER the coderefs are declared.
robert@0 7
robert@0 8 use strict;
robert@0 9 use CGI::Ajax;
robert@0 10 use CGI;
robert@0 11
robert@0 12 my $q = new CGI;
robert@0 13
robert@0 14 my $exported_fx = sub {
robert@0 15 my $value_a = shift;
robert@0 16 my $iq = new CGI;
robert@0 17 my $a = $q->param('a');
robert@0 18 my $b = $q->param('b');
robert@0 19 my $test = $q->param('test');
robert@0 20 return(
robert@0 21 'entered value was: ' . $value_a .
robert@0 22 '<br/>a was: ' . $a . "..." .
robert@0 23 '<br/>b was: ' . $b . "..." .
robert@0 24 '<br/>test was: ' . $test . "..."
robert@0 25 );
robert@0 26 };
robert@0 27
robert@0 28
robert@0 29 my $Show_Form = sub {
robert@0 30 my $html = "";
robert@0 31 $html .= <<EOT;
robert@0 32 <HTML>
robert@0 33 <HEAD><title>CGI::Ajax Example</title>
robert@0 34 </HEAD>
robert@0 35 <BODY>
robert@0 36 <form>
robert@0 37 this javascript object is sent in as an argument:
robert@0 38 {'a':123,'b':345,'test':'123 Evergreen Terrace'}
robert@0 39 <br/><br/>
robert@0 40 Enter something else:&nbsp;
robert@0 41 <input type="text" name="val1" size="6" onkeyup="myfunc(
robert@0 42 ['val1',{'a':123,'b':345,'test':'123 Evergreen Terrace'} ], 'resultdiv' ); return true;"><br>
robert@0 43
robert@0 44 <hr>
robert@0 45 <DIV id="resultdiv" style="border: 1px solid black; width: 440px; height: 80px; overflow: auto">
robert@0 46 </div>
robert@0 47 </form>
robert@0 48 </BODY>
robert@0 49 </HTML>
robert@0 50 EOT
robert@0 51
robert@0 52 return $html;
robert@0 53 };
robert@0 54
robert@0 55 my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx);
robert@0 56 $pjx->JSDEBUG(2);
robert@0 57 $pjx->DEBUG(2);
robert@0 58 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page
robert@0 59