diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/BoosterPack/pjx_radio.pl	Mon Sep 27 16:57:26 2010 -0400
     1.3 @@ -0,0 +1,49 @@
     1.4 +#!/usr/bin/perl
     1.5 +use strict;
     1.6 +use CGI::Ajax 0.57;
     1.7 +use CGI;
     1.8 +
     1.9 +my $q = new CGI;  # need a new CGI object
    1.10 +
    1.11 +# compose our list of functions to export to js
    1.12 +my %hash = ( 'myFunc'         => \&perl_func,);
    1.13 +
    1.14 +my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object
    1.15 +
    1.16 +$pjx->DEBUG(1);   # turn on debugging
    1.17 +$pjx->JSDEBUG(1); # turn on javascript debugging, which will place a
    1.18 +                  #  new div element at the bottom of our page showing
    1.19 +                  #  the asynchrously requested URL
    1.20 +
    1.21 +print $pjx->build_html( $q, \&Show_HTML ); # this builds our html
    1.22 +                                           #  page, inserting js
    1.23 +
    1.24 +# This subroutine is responsible for outputting the HTML of the web
    1.25 +# page. 
    1.26 +sub Show_HTML {
    1.27 +  my $html = <<EOT;
    1.28 +<HTML>
    1.29 +<HEAD><title>Radio Example</title>
    1.30 +</HEAD>
    1.31 +<BODY>
    1.32 +<form>
    1.33 +<DIV id="radiobuttons" onclick="myFunc( ['radio1'], ['result'] );"> 
    1.34 +<input TYPE="radio" ID="radio1" NAME="radio1" VALUE="red">red 
    1.35 +<input TYPE="radio" ID="radio1" NAME="radio1" VALUE="blue">blue 
    1.36 +<input TYPE="radio" ID="radio1" NAME="radio1" VALUE="yellow">yellow 
    1.37 +<input TYPE="radio" ID="radio1" NAME="radio1" VALUE="green">green 
    1.38 +</DIV> 
    1.39 +<div id='result'> </div>
    1.40 +</form>
    1.41 +</BODY>
    1.42 +</HTML>
    1.43 +EOT
    1.44 +
    1.45 +  return($html);
    1.46 +}
    1.47 +
    1.48 +# this is the exported function 
    1.49 +sub perl_func {
    1.50 +  $a = shift;
    1.51 +  return $a . " was selected"; 
    1.52 +}