-1

I have a form where i have two submit buttons

<button name="save" type="submit" id="save" class="btn btn-danger">Save <span class="glyphicon glyphicon-send"></span></button>
<button name="send" type="submit" id="send" class="btn btn-danger">Send For Approval <span class="glyphicon glyphicon-save-file"></span></button>

use the following to process in java-script

$('form#estimations').on('submit' ,function(){
    // my code
}

So depending on button press i want to have different code for each button but within the same function.

I have tried checking on stack overflow but most answers revolve around on click events but i am using .on functionality.

Krishneel Singh
  • 324
  • 1
  • 8
  • 16
  • 4
    You'll most likely want to use `.on('click'` on the individual buttons that you want to be able to tell the difference between. – CollinD Dec 27 '18 at 21:32
  • add an argument to `function()` ... because it is called with one anyway ... `function(e){ console.log(e.originalEvent.explicitOriginalTarget.id);` ... no need to use click event instead that way – Jaromanda X Dec 27 '18 at 21:39

1 Answers1

0

You can grab the name of the button if you change to click

var name = $(this).attr("name");
Patrick Simard
  • 2,294
  • 3
  • 24
  • 38