tags:

views:

52

answers:

3

I'm using the JQuery Form Plugin (http://jquery.malsup.com/form/) to create an Ajax Form.

I am trying put two submit buttons to handle Form Submit and Form Save operations. I need to submit to two different urls depending on the operation I want to perform: Submit or Save.

I'm not very sure how I can get the value of the actual submit button that was clicked, and then submit the form via AJAX based on this information. I need a little help with this.

For the record, I'm using code syntax similar to what is listed below (this is not the actual code):

// prepare Options Object 
var options = { 
    target:     '#divToUpdate', 
    url:        'comment.php', 
    success:    function() { 
        alert('Thanks for your comment!'); 
    } 
}; 

// pass options to ajaxForm 
$('#myForm').ajaxForm(options);

Thanks

A: 

Attach the js to both the buttons and in the js do the form submission based on url

<input id="submit" type="submit" value="Submit"/>  
  <script type="text/javascript">  
  $(function() {  
    $("#submit").click(function() {  

    }  
}  
</script>
lalit
A: 

use normal button and check which button is clicked(by checking value property), then submit the form manually.........

Deepak
A: 

I probably didn't research this thoroughly before posting. My apologies.

I did this to sort it out (this is a code sample):

var $_ = jQuery;

$_(document).ready(function() { 
    $_("#id_submitbutton_1").click(function(){
       $_("#form_id").ajaxForm(options_1);
    });
    $_("#id_submitbutton_2").click(function(){
       $_("#form_id").ajaxForm(options_2);
    });
});

Thanks Lalit, I think you were closer to what I needed to do.

Cheers.

Chuck Ugwuh