tarunkhanna has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl use CGI; $co = new CGI; print $co->header; print $co->start_html(); print $co->center($co->h1('Press button')); print $co->image_button(-name=>'button',-src=>'image.gif',-onClick=>"f +irst.cgi"); print $co->end_html;

Hi, In the above code..when I click the image button...it doesn't run first.cgi script.

At the bottom of Internet Explorer, Error on page occurs when I click the image_button

In short, -onClick is not working...What shall I do??

Regards

Replies are listed 'Best First'.
Re: CGI button -onClick not working
by keszler (Priest) on Sep 28, 2011 at 14:40 UTC

    The onClick event occurs in the web browser and - assuming javascript is enabled - runs javascript in the browser. You appear to be intending that the button click runs first.cgi on the webserver.

    If that is the case, HTML Forms and Input would be a good place to start learning. Once you have the basics of HTML forms, then the FORMS section of the CGI documentation will be easier to comprehend.

Re: CGI button -onClick not working
by AlexTape (Monk) on Sep 28, 2011 at 14:03 UTC
    perhaps -onclick=>"parent.location.href=\'first.cgi\';"
    itīs not a perl problem.. itīs nescience about javascript..
    $perlig =~ s/pec/cep/g if 'errors expected';
    A reply falls below the community's threshold of quality. You may see it by logging in.