Re: button tag

Luis Fernando Llana Díaz wrote:
<blockquote>
>   I have to make a form where some input controls should send
> the form when their contents is changed. It is easely done with 
> javascript, but in orden to make it accesible I am considering to
> attach a button to each of these "auto-submuit" input controls.
(message clipped here)
> Pleas, could anyone indicate me what is the correct interpretation.
</blockquote>

I have come across a similar problem before, having a form with several submit 
buttons, each performing a different action.

I assume that you want to use type=button rather than type=submit because a 
value in a submit button which makes sense to a user is not a good input value 
for the processing software.

My solution was to substitute an appropriate value in the processing software.

Form Example:

<form method="get" action="http://www.foo.com/bar/baz.cgi">
....
....
<fieldset><legend>Actions (Selecting will submit form)</legend>
<input type="submit" name="action" value="First Button" />
<input type="submit" name="action" value="Second Button" />
<input type="submit" name="action" value="Third Button" />
</fieldset>
</form>

Code example, in Perl, using CGI module for simplicity.  (I don't know PHP, but 
assume that it must have regular expressions.)

# Initialise CGI module
use CGI;
my $q=new CGI;

# Set variable $action to be the value of the submit button selected
my $action=$q->param('action');

# Use regular expressions to substitute a "sensible" value
# so that "First Button" becomes "1", etc.
$action=~s/First Button/1/;
$action=~s/Second Button/2/;
$action=~s/Third Button/3/;


Hope this helps.

Cheers

M

-- 
Matthew Smith
Kadina Business Consultancy
South Australia
http://www.kbc.net.au

Received on Monday, 29 November 2004 20:55:32 UTC