Mercurial > boosterpack
view scripts/pjx_objects_2_url.pl @ 9:9652dc713ba6 boosterpack
working on adding to rlmcintyre.com
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 26 Jun 2010 20:06:08 -0400 |
parents | 477258d09353 |
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.5 #6 # NB The CGI::Ajax object must come AFTER the coderefs are declared.8 use strict;9 use CGI::Ajax;10 use CGI;12 my $q = new CGI;14 my $exported_fx = sub {15 my $value_a = shift;16 my $iq = new CGI;17 my $a = $q->param('a');18 my $b = $q->param('b');19 my $test = $q->param('test');20 return(21 'entered value was: ' . $value_a .22 '<br/>a was: ' . $a . "..." .23 '<br/>b was: ' . $b . "..." .24 '<br/>test was: ' . $test . "..."25 );26 };29 my $Show_Form = sub {30 my $html = "";31 $html .= <<EOT;32 <HTML>33 <HEAD><title>CGI::Ajax Example</title>34 </HEAD>35 <BODY>36 <form>37 this javascript object is sent in as an argument:38 {'a':123,'b':345,'test':'123 Evergreen Terrace'}39 <br/><br/>40 Enter something else: 41 <input type="text" name="val1" size="6" onkeyup="myfunc(42 ['val1',{'a':123,'b':345,'test':'123 Evergreen Terrace'} ], 'resultdiv' ); return true;"><br>44 <hr>45 <DIV id="resultdiv" style="border: 1px solid black; width: 440px; height: 80px; overflow: auto">46 </div>47 </form>48 </BODY>49 </HTML>50 EOT52 return $html;53 };55 my $pjx = CGI::Ajax->new( 'myfunc' => $exported_fx);56 $pjx->JSDEBUG(2);57 $pjx->DEBUG(2);58 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page