• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

call to subroutine using button

What is the syntax for referencing a subroutine call from submit button using Perl/CGI?
1 Solution
Your question is a little unclear, but I think what you're asking is how can you call a subroutine based on which submit button on a form was pressed.

In order to do this, give each submit button on your HTML form the same "NAME" attribute and different "VALUE" attributes (the VALUE attributes will be what is displayed on the button).  Then in your CGI script, you can check the value of the submit button's value.  For example, your HTML could be something like:

<INPUT TYPE=submit NAME="sub" VALUE="Submit1">
<INPUT TYPE=submit NAME="sub" VALUE="Submit2">

Then in your CGI script, use the following code (assuming your CGI variables get put into a hash called %in):

if ($in{sub} eq "Submit1") {
} elsif ($in{sub} eq "Submit2") {

I hope this is what you were asking.  If not, could you clarify a little more?
EppsgAuthor Commented:
Adjusted points to 40
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now