Mercurial > boosterpack
view 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 |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe2 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 }