Hi,
 
Thanks for your tips. This is actually similar to what I have right now. The problem with calling the same script again, that is, refreshing the entire page when the checkbox is clicked is that the checkbox is also refreshed which means it no longer appears to be clicked.
 
I was looking to do something where a person clicks 2 of the 4 checkboxes and only the image/graph changes. Then they unclick say one of the check boxes to see the image/graph change again. So they need to see what boxes are checked and what arent.
 
Do I think I can still do that somehow when refreshing the entire script?
 
thanks
dhivya
[EMAIL PROTECTED] wrote: -----

To: perl-win32-web@listserv.ActiveState.com
From: Lachlan <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
Date: 07/24/2007 10:50PM
Subject: Re: having a html button/check box call a perl subroutine

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',-
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'  
> >";
>
> 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

_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to