List Info

Thread: having a html button/check box call a perl subroutine




having a html button/check box call a perl subroutine
country flaguser name
United States
2007-07-23 16:02:58

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

Re: having a html button/check box call a perl subroutine
country flaguser name
Singapore
2007-07-23 21:53:25
Are you sure you want to run Perl on the client side?
Usually it's a 
policy challenge to do that on all the desktops.

If you really know what you are talking about, then you can
google 
'perlscript clientside' to get some good documentation on
this.

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-Weblistserv.ActiveState.com
> To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
>   

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

Re: having a html button/check box call a perl subroutine
country flaguser name
Australia
2007-07-25 00:50:25
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-Weblistserv.ActiveState.com
> To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

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

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )