Click to See Complete Forum and Search --> : Which submit button was pressed


Rick Bull
12-15-2002, 04:58 PM
Is there a way I can find which submit button was pressed in a form like this:


<form action="..."><p>
<input type="submit" name="button1" value="value1" />
<input type="submit" name="button2" value="value2" />
</p></form>


I want to have a confirm box appear when the user presses the first submit button only. I've checked the event variable in the onsubmit event handler with a for-in loop, but can't find what I'm looking for.

khalidali63
12-15-2002, 11:31 PM
as a matter of fact you can get the button name in NS as well

alert(e.target.name)

will give you the name of the button u click

Khalid

Rick Bull
12-16-2002, 06:07 AM
OK thanks guys. But Dave I tried what you said and it just gives me a null string. I tried that before and thought it should work. :confused: