3

I have a form with two submits buttons, one called 'display' and the other called 'disenrol'. The display submit doesn't need confirmation whereas the other does. Originally I was going to use

onsubmit="return confirm('Are you sure you want to remove the modules?');"

But of course that won't work because it reacts to both of the submits. Is there a way I can specify which submit it should worth with? (I'm quite new to javascript so please be gentle with me)

Thanks

tatty27
  • 1,553
  • 4
  • 34
  • 73
  • Possible duplicate of [How to use onsubmit() show a confirmation with multiple submit buttons?](http://stackoverflow.com/questions/18038085/how-to-use-onsubmit-show-a-confirmation-with-multiple-submit-buttons) – Ciro Santilli OurBigBook.com May 10 '16 at 09:27

1 Answers1

6

Try this:

<input type="submit" onclick="return confirm('Are you sure you want to remove the modules?');" value="submit1" />
karaxuna
  • 26,752
  • 13
  • 82
  • 117
  • Just FYI, this won't work if the user performs the submission without using the mouse, e.g., presses Enter. – apsillers Dec 04 '12 at 16:45
  • it is asked here: http://stackoverflow.com/questions/2066162/how-can-i-get-the-button-that-caused-the-submit-from-the-form-submit-event – karaxuna Dec 04 '12 at 16:52