Mercurial > rlmcintyre
view 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 source
1 #!/usr/bin/perl2 use strict;3 use CGI::Ajax 0.57;4 use CGI;6 my $q = new CGI; # need a new CGI object8 # compose our list of functions to export to js9 my %hash = ( 'myFunc' => \&perl_func,);11 my $pjx = CGI::Ajax->new( %hash ); # this is our CGI::Ajax object13 $pjx->DEBUG(1); # turn on debugging14 $pjx->JSDEBUG(1); # turn on javascript debugging, which will place a15 # new div element at the bottom of our page showing16 # the asynchrously requested URL18 print $pjx->build_html( $q, \&Show_HTML ); # this builds our html19 # page, inserting js21 # This subroutine is responsible for outputting the HTML of the web22 # 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">red32 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="blue">blue33 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="yellow">yellow34 <input TYPE="radio" ID="radio1" NAME="radio1" VALUE="green">green35 </DIV>36 <div id='result'> </div>37 </form>38 </BODY>39 </HTML>40 EOT42 return($html);43 }45 # this is the exported function46 sub perl_func {47 $a = shift;48 return $a . " was selected";49 }