annotate BoosterPack/scripts/.svn/text-base/pjx_change_encoding.pl.svn-base @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
rev   line source
rlm@0 1 #!C:/strawberry/perl/bin/perl.exe
rlm@0 2
rlm@0 3 use strict;
rlm@0 4 use CGI::Ajax;
rlm@0 5 use CGI;
rlm@0 6
rlm@0 7 my $func = sub {
rlm@0 8 my $input = shift;
rlm@0 9 return "got input: $input " ;
rlm@0 10 };
rlm@0 11
rlm@0 12
rlm@0 13 sub Show_HTML {
rlm@0 14 my $html = <<EOT;
rlm@0 15
rlm@0 16 <html>
rlm@0 17 <head><title>CGI::Ajax Example</title>
rlm@0 18
rlm@0 19 </head>
rlm@0 20 <body>
rlm@0 21 <form>
rlm@0 22 Enter Something:&nbsp;
rlm@0 23 <input type="text" name="val1" id="val1" size="6" onkeyup="jsfunc( ['val1'], 'result' ); return true;"><br>
rlm@0 24 Enter Something:&nbsp;
rlm@0 25 <hr>
rlm@0 26 <div id="result" style="border: 1px solid black;
rlm@0 27 width: 440px; height: 80px; overflow: auto">
rlm@0 28 </div>
rlm@0 29
rlm@0 30 </form>
rlm@0 31 </body>
rlm@0 32 </html>
rlm@0 33
rlm@0 34 EOT
rlm@0 35
rlm@0 36 }
rlm@0 37
rlm@0 38 my $cgi = new CGI(); # create a new CGI object
rlm@0 39 my $pjx = new CGI::Ajax( 'jsfunc' => $func );
rlm@0 40 # the default encoding for CGI::Ajax is encodeURIComponent;
rlm@0 41 # if this causes problems, you can use escape or your own javascript
rlm@0 42 # function;
rlm@0 43 $pjx->js_encode_function('escape');
rlm@0 44 print $pjx->build_html($cgi,\&Show_HTML);