Firstly, have you looked into combining CSS with your
javascript?
There are plenty of resources on the web that describe how
to use the
inline parameter to display and hide content.
You won't be able to run a perl sub after your page has been
rendered
unless you run your script again.
One of the most obvious ways is to refresh the page (ie. run
the script
again) when the checkbox is pressed.
I haven't done this with a checkbox but I have used a
round-about way
of getting a javascript action button to run a Perl sub.
I used a simple javascript action button. With the CGI
module I used:
$cgiObject->button(-name=>'nameofbutton',-value=>'
Label of
Button',-onClick=>"window.open('nameOfScript?
x=param1&y=param2&z=param3'... )")
A javascript action button is displayed and when clicked
opens a new
window and goes to the address specified using the
particular params.
One of the params is a flag to indicate a basic function
mode for the
script; basically which sub should be run (in the example
'x').
Towards the start of my script I have something like this
($qaz is the
CGI object):
if (defined( $qaz->param('x') )){
if ($qaz->param('x') eq 'value1'){
runSub1();
}
if ($qaz->param('x') eq 'value2'){
runSub2();
}
...
}
You should be able to do something similar with a checkbox
using
onClick. Use the window.location.replace(x) function to
reload the
current page.
Of course, 'x' represents the script name with the parameter
list. If
you use the same sub to set the content and use the param
list to alter
what is set by that sub then code duplication is minimised -
you don't
need multiple subs to set up different page content if the
'page' is
practically the same.
Cheers,
Lachlan.
On 24 Jul 2007, at 7:02, Dhivya Arasappan/O/VCU wrote:
> Hi everyone,
>
> I'm writing a perl program in which I'm setting up a
html checkbox
> such that when it is clicked, a perl subroutine is
called.
>
> I know that I can call a javascript function when a
checkbox is
> clicked in the following way:
>
> print "<input type='checkbox' name='check'
value='checkbox'
> onClick='javascriptfn();'>";
>
> But how can I use the same checkbox to call a perl
subroutine?
>
> Any kind of guidance would be really appreciated.
>
> thanks
>
> dhivya
arasappan_______________________________________________
> Perl-Win32-Web mailing list
> Perl-Win32-Web listserv.ActiveState.com
> To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web listserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
|