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
> </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> </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 <lashley@turing.une.edu.au><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 <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 <BR> unless you run your script again.<BR>One of the most obvious ways is to re
fresh the page (ie. run the script <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 <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->button(-name=>'nameofbutton',-value=>' La
bel of <BR> Button',-onClick=>"window.open('nameOfScript? <BR>x=param1&y=param2&
amp;z=param3'... )")<BR> <BR>A javascript action button is displayed and when clicked opens a
new <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 <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 <BR> CGI object):<BR><BR>if (defined( $qaz->param(
'x') )){<BR> <SPAN> </SPAN>if ($qaz->param('x') eq 'value1'){<BR><S
PAN> </SPAN><SPAN> </SPAN>runSub1();<BR><SPAN>
</SPAN> }<BR><SPAN> </SPAN>if ($qaz->param(
'x') eq 'value2'){<BR> <SPAN> </SPAN><SPAN> </S
PAN> runSub2();<BR><SPAN> </SPAN>}<BR><SPAN> </
SPAN> ...<BR>}<BR><BR>You should be able to do something similar with a checkbox using
<BR> onClick. Use the window.location.replace(x) function to reload the <BR>current pag
e.<BR> Of course, 'x' represents the script name with the parameter list. If <BR>you us
e the same sub to set the content and use the param list to alter <BR> what is set by t
hat sub then code duplication is minimised - you don't <BR> need multiple subs to set u
p different page content if the 'page' is <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>
> Hi everyone,<BR> > <BR>> I'm writing a perl program in which I'm setting up&
nbsp;a html checkbox <BR> > such that when it is clicked, a perl subroutine is calle
d.<BR> > <BR>> I know that I can call a javascript function when a checkbox
is <BR> > clicked in the following way:<BR>><BR>> print "<input type='check
box' name='check' value='checkbox' <BR> > onClick='javascriptfn();'>";<BR>><BR
> > But how can I use the same checkbox to call a perl subroutine?<BR>><BR>> Any kin
d of guidance would be really appreciated.<BR> ><BR>> thanks<BR>><BR>> dhivya ara
sappan_______________________________________________<BR> > Perl-Win32-Web mailing list<BR
> > Perl-Win32-Web@[...].com<BR>> 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
|