Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q619 If a form has two submit buttons with the same name and different values, how can an onSubmit handler tell which button submitted the form?

irt.org | Knowledge Base | JavaScript | Form 7.2 | Q619 [ previous next ]

Q619 If a form has two submit buttons with the same name and different values, how can an onSubmit handler tell which button submitted the form?

By using the onClick event handler:

<FORM onSubmit="alert(button + ' pressed')">
<INPUT TYPE="SUBMIT" onClick="button=this.value" VALUE="Button One">
<INPUT TYPE="SUBMIT" onClick="button=this.value" VALUE="Button Two">
</FORM>

Feedback on 'Q619 If a form has two submit buttons with the same name and different values, how can an onSubmit handler tell which button submitted the form?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.