annotate BoosterPack/scripts/.svn/text-base/pjx_JSON.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 use strict;
rlm@0 3 use CGI::Ajax;
rlm@0 4 use CGI;
rlm@0 5
rlm@0 6 my $q = new CGI;
rlm@0 7
rlm@0 8 my $Show_Form = sub {
rlm@0 9 my $html = "";
rlm@0 10 $html .= <<EOT;
rlm@0 11 <HTML>
rlm@0 12 <HEAD><title>CGI::Ajax JSON Example</title>
rlm@0 13 <script>
rlm@0 14 handle_return = function(vv){
rlm@0 15 document.getElementById('object_display').innerHTML = vv;
rlm@0 16 eval(vv); // this gives you 'var jsonObj' here in javascript;
rlm@0 17 // alert(jsonObj);
rlm@0 18 var div = document.getElementById('parsed');
rlm@0 19 div.innerHTML = "</b>key : value<b><br/>";
rlm@0 20 for(var key in jsonObj){
rlm@0 21 div.innerHTML += key + " => " + jsonObj[key] + "<br/>";
rlm@0 22 }
rlm@0 23
rlm@0 24 }
rlm@0 25 </script>
rlm@0 26 </HEAD>
rlm@0 27 <BODY>
rlm@0 28 <H2> Get The Letter Following the One you Enter </H2>
rlm@0 29 <form>
rlm@0 30 Enter Number:
rlm@0 31 <input type="text" id="val1" size="6" value='abc' onkeyup="json(['val1'], [handle_return]);">
rlm@0 32 <br/><br/>The JavaScript Object:<br/>
rlm@0 33 <div id="object_display" style="width:500px;height:200px;">
rlm@0 34
rlm@0 35 </div>
rlm@0 36 <br/> After Parsing (use eval) <br/>
rlm@0 37 <div id="parsed" style="width:500px;height:200px;">
rlm@0 38
rlm@0 39 </div>
rlm@0 40
rlm@0 41 </form>
rlm@0 42 </BODY>
rlm@0 43 </HTML>
rlm@0 44 EOT
rlm@0 45
rlm@0 46 return $html;
rlm@0 47 };
rlm@0 48
rlm@0 49 my $pjx = CGI::Ajax->new('json' => 'pjx_JSON_out.pl');
rlm@0 50 $pjx->JSDEBUG(1);
rlm@0 51 $pjx->DEBUG(1);
rlm@0 52 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page