note
George_Sherston
In that case you would need the form action to be the <em>script</em>, and submit another field which the script uses to find the right subroutine. You could use a hidden field. But a nice way to do it IMHO is with the submit button. Since the value field in a Submit button only gets submitted with the form when that particular button is pressed, you have the option of different buttons within the same form. For example, in the html:
<code>
<FORM ACTION="yourscript.pl" METHOD="POST">
<!-- insert other form inputs here -->
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="Run Foo">
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="Run Bar">
<INPUT TYPE="SUBMIT" NAME="Action" VALUE="Store Event">
</FORM>
</code>
Then in the script (in this example saved as <code>yourscript.pl</code>) you could have something like
<code>
use CGI qw/:standard/;
if (param('Action') and param('Action') eq 'Run Foo') {
foo();
}
elsif (param('Action') and param('Action') eq 'Run Bar') {
bar();
}
elsif (param('Action') and param('Action') eq 'Store Event') {
store_event();
}
else {
print
header,
start_html('Ack!'),
h1 'you have to call this from the form!',
end_html;
}
</code>
<br><br>§ <A HREF="http://www.sprogress.com">George Sherston</A>
208145
208161