in reply to Re^3: CGI button -onClick not working
in thread CGI button -onClick not working

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^5: CGI button -onClick not working
by Corion (Patriarch) on Sep 29, 2011 at 08:27 UTC

    You will need to learn about HTML (and possibly Javascript).

Re^5: CGI button -onClick not working
by zentara (Cardinal) on Sep 29, 2011 at 08:27 UTC
    Here is a simple example
    #!/usr/bin/perl use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use strict; use diagnostics; my $who = param('name') || 'unknown'; print header(); print <<HERE; <html> <head> <title>Hello to $who</title> <script language="JavaScript"> <!-- Begin function drawAlert () { alert ("Hello $who !"); } // End --> </script> </head> <body> <center> <form> <input type=button value="Click here to try the JavaScript!" onClick="drawAlert()"> </form> </center> </body> </html> HERE

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re^5: CGI button -onClick not working
by Anonymous Monk on Sep 29, 2011 at 08:32 UTC

    Yeah, I know that perl doesn't run in the browser. But the point is, I want to run a function when I click the button. How to do that??

    Asked and answered :)

    You've decided on onclick, and onclick is javascript, ie , in the browser only

    Your options are 1) submit a form like keszler showed or 2) use javascript to make a http request like perlig showed

    Is that clearer?