in reply to [Solved]:How to catch event when button (which is NOT submit button) is clicked.

As suggested by choroba, I used two submit buttons and that got me what I wanted to do. Code is something like:
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; use CGI qw/:standard/; my $query = new CGI; print $query->header; my $formStatus = $query->param('submitButton'); my $buttonStatus = $query->param('resetButton'); print "Value of \$formStatus is: $formStatus". localtime()."\n"; print "Value of \$buttonStatus is: $buttonStatus". localtime()."\n"; print "<html>\n"; print "<head>\n"; print "</head>\n"; print "<body>\n"; print "<form id=\"form1\" method=\"post\" class=\"admin-form\">\n" +; print "<input type=\"submit\" name=\"submitButton\" value=\"Submit +\" id=\"button1\"/>\n"; print"<input type=\"submit\" name=\"resetButton\" value=\"Reset\" +id=\"button2\"/>\n"; print "</form>\n"; print "</body>\n"; print "</html>\n";
  • Comment on [Solved]: How to catch event when button (which is NOT submit button) is clicked.
  • Download Code

Replies are listed 'Best First'.
Re: [Solved]: How to catch event when button (which is NOT submit button) is clicked.
by choroba (Cardinal) on Nov 12, 2015 at 08:36 UTC
    That's not exactly what I suggested. The submit buttons have different names, but it's useless - you can never press both of them at the same time. Give them the same name and a different value, then you'll have to only check one parameter.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks again, choroba. Yes having same name and different values would need checking only one parameter value (which I was already doing for submitButton). At present I am checking two different parameters one for submitButton and second for resetButton (and I don't need to click both at same time). Though it also gives me what I wanted to do but your suggestion will make it more efficient.