annotate scripts/pjx_radio.pl @ 10:3b52ac950753 boosterpack tip

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