-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.

2
  • 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. Commented Dec 27, 2018 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 Commented Dec 27, 2018 at 21:39

1 Answer 1

0

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

var name = $(this).attr("name"); 
Sign up to request clarification or add additional context in comments.

1 Comment

I said if you change to click

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.