You are here: Re: Forms and submit buttons « HTML « IT news, forums, messages
Re: Forms and submit buttons

Posted by Jonathan N. Little on 04/17/06 18:01

nettleby@googlemail.com wrote:
> I'm just learning about forms and the submit process. One thing I'm
> confused about is: if there are two submit buttons on a page, then is
> it necessary to have a name for both buttons, or just for one, in order
> that the server can differentiate between the buttons?
>
> for example:
>
> <form action="http://www.htmlcodetutorial.com/cgi-bin/mycgi.pl">
> Firstname:<input type="text" name="fname">
> <br>
> Surname:<input type="text" name="sname">
> <br>
> <input type = "submit" value="Update"/>
> <input type = "submit" value="Reset" name = "reset"/>
> </form>

In your example your reset button should be:

XHTML
<input type="reset" value="Reset" />

or HTML
<input type="reset" value="Reset">

>
> You would get two different strings being submitted here, for the two
> buttons. Is this a valid way of doing things?

If you have more than one submit button if you five them different names
then your receiving script can "see" which button was activated and
process accordingly

<input type="submit" value="Do One Thing" name="do_this">
<input type="submit" value="Do Something Else" name="do_that">

so if the 1st submit button was click the receiving script would see
this key value pair:

do_this="Do One Thing"

or with the second

do_that="Do Something Else"

HTH

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация