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