Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q265 If I have two identically named submit buttons, but with different values, how can I tell which one was pressed?

You are here: irt.org | FAQ | JavaScript | Form | 7.2 | Q265 [ previous next ]

<SCRIPT LANGUAGE="JavaScript"><!--
var button = 0;

function test(val) {
    button = val;
}

function check() {
    alert('Button ' + button + ' pressed');
}
//--></SCRIPT>

<FORM onSubmit="check()">
<INPUT TYPE="SUBMIT" NAME="xxxx" VALUE="Button 1" onClick="test('1')">
<INPUT TYPE="SUBMIT" NAME="xxxx" VALUE="Button 2" onClick="test('2')">
</FORM>

©2018 Martin Webb