robert@0: #!C:/strawberry/perl/bin/perl.exe robert@0: robert@0: # pjx_chained.pl: Multiple exported perl subs, and the exported robert@0: # functions are chained to an event, like this... robert@0: # onclick="func1(['in1'],['out1']); func2(['in1'],['out2']);" robert@0: robert@0: use strict; robert@0: use CGI::Ajax; robert@0: use CGI; robert@0: robert@0: my $q = new CGI; robert@0: robert@0: my $multiply = sub { robert@0: my $a = shift; robert@0: my $b = shift; robert@0: return $a * $b; robert@0: }; robert@0: robert@0: my $divide = sub { robert@0: my $a = shift; robert@0: my $b = shift; robert@0: return $a / $b; robert@0: }; robert@0: robert@0: my $Show_Form = sub { robert@0: my $html = ""; robert@0: $html .= < robert@0: CGI::Ajax Chained function Example robert@0: robert@0: robert@0:
robert@0: Enter Number: robert@0: robert@0: robert@0:

robert@0: robert@0: robert@0: robert@0: robert@0: robert@0:
robert@0: robert@0: robert@0: EOT robert@0: return $html; robert@0: }; robert@0: robert@0: my $pjx = CGI::Ajax->new( 'multiply' => $multiply, 'divide' => $divide); robert@0: $pjx->JSDEBUG(1); robert@0: $pjx->DEBUG(1); robert@0: print $pjx->build_html($q,$Show_Form); # this outputs the html for the page