I have a JSP page, which has standard form on it. I have two buttons, each perform a different action when pressed, and the form is submitted - action 1 and action 2.
I originally had this set up for one button, so it was all done through the following and worked fine:
$('#form').submit( function() { .... }
But now I have two buttons, I want it to do the same, but how to find which button I pressed.
I could do this through the .click function, but I dont want to break my existing form.submit functionality.
Below is my code for this - which doesn't work:
    $('#form').submit( function() {
        // Set the field array variables with data
        $('button[name="action1"], [name="action2"]').each(function(index) {
            alert('index : ' + index );
            alert('value : ' + this.value);
        });
        $('button[name="action1"]').click(function(e) { 
            alert('ac1 clicked');
        }); 
        $('button[name="action2"]').click(function(e) { 
            alert('ac2 clicked');
        }); 
my html buttons are:
            <button id="submitButton" name="action1" value="action1" type="submit">action 1</button>
            <button id="submitButton" name="action2" value="action2" type="submit">action 2</button>
Is there a way I can do this inside my form.submit, or a way to do the .click, which then submits the form. I am a little lost for a solution on this?
Please help :)
 
     
     
     
     
     
    