ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-web
perl-win32-web
Re: having a html button/check box call a perl subroutine
by Dhivya Arasappan/O/VCU other posts by this author
Jul 25 2007 8:45AM messages near this date
view in the new Beta List Site
Re: having a html button/check box call a perl subroutine | Re: having a html button/check box call a perl subroutine
<FONT face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size=2> <DIV>Hi,</DIV><DIV
> &nbsp;</DIV><DIV>To be more clear, I wanted to just refresh the subroutine that generates t
he graph when the checkbox is clicked, not refresh the entire page. Is that possible?</DIV> <
DIV> &nbsp;</DIV><DIV>thanks</DIV><DIV>dhivya<BR></DIV><FONT color=#990099>-----perl-win32-we
b-bounces@[...].com wrote: -----<BR> <BR></FONT><BLOCKQUOTE style="PADDING-RIGHT: 0px; PADDIN
G-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> To: perl-w
in32-web@[...].com<BR> From: Lachlan &lt;lashley@turing.une.edu.au&gt;<BR>Sent by: perl-win32
-web-bounces@[...].com<BR> Date: 07/24/2007 10:50PM<BR>Subject: Re: having a html button/chec
k box call a perl subroutine<BR> <BR><FONT face="Default Monospace,Courier New,Courier,monosp
ace" size=2> Firstly, have you looked into combining CSS with your javascript?<BR>There are p
lenty of resources on the web that describe how to use the &nbsp;<BR> inline parameter to dis
play and hide content.<BR> <BR>You won't be able to run a perl sub after your page has been r
endered &nbsp;<BR> unless you run your script again.<BR>One of the most obvious ways is to re
fresh the page (ie. run the script &nbsp;<BR> again) when the checkbox is pressed.<BR><BR>I h
aven't done this with a checkbox but I have used a round-about way &nbsp;<BR> of getting a ja
vascript action button to run a Perl sub.<BR> I used a simple javascript action button. With 
the CGI module I used:<BR> <BR>$cgiObject-&gt;button(-name=&gt;'nameofbutton',-value=&gt;' La
bel of &nbsp;<BR> Button',-onClick=&gt;"window.open('nameOfScript? <BR>x=param1&amp;y=param2&
amp;z=param3'... )")<BR> <BR>A javascript action button is displayed and when clicked opens a
 new &nbsp;<BR> window and goes to the address specified using the particular params.<BR>One 
of the params is a flag to indicate a basic function mode for the &nbsp;<BR> script; basicall
y which sub should be run (in the example 'x').<BR> <BR>Towards the start of my script I have
 something like this ($qaz is the &nbsp;<BR> CGI object):<BR><BR>if (defined( $qaz-&gt;param(
'x') )){<BR> <SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>if ($qaz-&gt;param('x') eq 'value1'){<BR><S
PAN> &nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>runSub1();<BR><SPAN>
&nbsp;&nbsp;&nbsp;&nbsp;</SPAN> }<BR><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>if ($qaz-&gt;param(
'x') eq 'value2'){<BR> <SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</S
PAN> runSub2();<BR><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>}<BR><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;</
SPAN> ...<BR>}<BR><BR>You should be able to do something similar with a checkbox using &nbsp;
<BR> onClick. Use the window.location.replace(x) function to reload the &nbsp;<BR>current pag
e.<BR> Of course, 'x' represents the script name with the parameter list. If &nbsp;<BR>you us
e the same sub to set the content and use the param list to alter &nbsp;<BR> what is set by t
hat sub then code duplication is minimised - you don't &nbsp;<BR> need multiple subs to set u
p different page content if the 'page' &nbsp;is &nbsp;<BR> practically the same.<BR><BR><BR>C
heers,<BR> Lachlan.<BR><BR><BR>On 24 Jul 2007, at 7:02, Dhivya Arasappan/O/VCU wrote:<BR><BR>
&gt; Hi everyone,<BR> &gt; &nbsp;<BR>&gt; I'm writing a perl program in which I'm setting up&
nbsp;a html checkbox &nbsp;<BR> &gt; such that when it is clicked, a perl subroutine is calle
d.<BR> &gt; &nbsp;<BR>&gt; I know that I can call a javascript function when&nbsp;a checkbox 
is &nbsp;<BR> &gt; clicked in the following way:<BR>&gt;<BR>&gt; print "&lt;input type='check
box' name='check' value='checkbox' &nbsp;<BR> &gt; onClick='javascriptfn();'&gt;";<BR>&gt;<BR
> &gt; But how can I use the same checkbox to call a perl subroutine?<BR>&gt;<BR>&gt; Any kin
d of guidance would be really appreciated.<BR> &gt;<BR>&gt; thanks<BR>&gt;<BR>&gt; dhivya ara
sappan_______________________________________________<BR> &gt; Perl-Win32-Web mailing list<BR
> &gt; Perl-Win32-Web@[...].com<BR>&gt; To unsubscribe: <A href="http://listserv.activestate.
com/mailman/mysubs" target=blank> http://listserv.ActiveState.com/mailman/mysubs</A><BR><BR>_
______________________________________________<BR> Perl-Win32-Web mailing list<BR>Perl-Win32-
Web@[...].com<BR> To unsubscribe: <A href="http://listserv.activestate.com/mailman/mysubs" ta
rget=blank> http://listserv.ActiveState.com/mailman/mysubs</A><BR></FONT></BLOCKQUOTE><BR></F
ONT> 
Thread:
Dhivya Arasappan/O/VCU
Lachlan
Dhivya Arasappan/O/VCU
Dhivya Arasappan/O/VCU
lashley
Bill Luebkert
Foo JH
Chip Hedler

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved