annotate BoosterPack/pjx_radio.pl @ 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 #!/usr/bin/perl
rlm@0 2 use strict;
rlm@0 3 use CGI::Ajax 0.57;
rlm@0 4 use CGI;
rlm@0 5
rlm@0 6 my $q = new CGI; # need a new CGI object
rlm@0 7
rlm@0 8 # compose our list of functions to export to js
rlm@0 9 my %hash = ( 'myFunc' => \&perl_func,);
rlm@0 10
rlm@0 11 my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object
rlm@0 12
rlm@0 13 $pjx->DEBUG(1); # turn on debugging
rlm@0 14 $pjx->JSDEBUG(1); # turn on javascript debugging, which will place a
rlm@0 15 # new div element at the bottom of our page showing
rlm@0 16 # the asynchrously requested URL
rlm@0 17
rlm@0 18 print $pjx->build_html( $q, \&Show_HTML ); # this builds our html
rlm@0 19 # page, inserting js
rlm@0 20
rlm@0 21 # This subroutine is responsible for outputting the HTML of the web
rlm@0 22 # page.
rlm@0 23 sub Show_HTML {
rlm@0 24 my $html = <<EOT;
rlm@0 25 <HTML>
rlm@0 26 <HEAD><title>Radio Example</title>
rlm@0 27 </HEAD>
rlm@0 28 <BODY>
rlm@0 29 <form>
rlm@0 30 <DIV id="radiobuttons" onclick="myFunc( ['radio1'], ['result'] );">
rlm@0 31 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="red">red
rlm@0 32 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="blue">blue
rlm@0 33 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="yellow">yellow
rlm@0 34 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="green">green
rlm@0 35 </DIV>
rlm@0 36 <div id='result'> </div>
rlm@0 37 </form>
rlm@0 38 </BODY>
rlm@0 39 </HTML>
rlm@0 40 EOT
rlm@0 41
rlm@0 42 return($html);
rlm@0 43 }
rlm@0 44
rlm@0 45 # this is the exported function
rlm@0 46 sub perl_func {
rlm@0 47 $a = shift;
rlm@0 48 return $a . " was selected";
rlm@0 49 }