udaya
udaya

Reputation: 9778

submitting a form with out using submit?

I want to submit a form without using submit button how can i do that?

Upvotes: 1

Views: 381

Answers (4)

Homer6
Homer6

Reputation: 15159

Use jquery's form methods to serialize the form variables and send via ajax.

http://api.jquery.com/category/forms/

You can add some javascript logic to ANY submit methods by passing a function to the form's submit event handler.

Eg.

$('#my_form').submit(function(){
  alert('Handler for .submit() called.');
  return false;
});

Returning false blocks the form from being submitted by all other methods (including the "traditional" submit button). You'd put your ajax code before the return statement.

or add bind the submit function to ANY dom element (image,button,etc.) Eg.

$('#my_cool_image').click(function() {
  $('#my_form').submit();
});

See more at http://api.jquery.com/submit/

Good Luck

Upvotes: 0

towe75
towe75

Reputation: 1470

Use javascript. Something like

document.forms["myform"].submit();

or

document.myform.submit();

You need to set the name (1. example) or id (2. example) attribute for your form to make this work.

Upvotes: 1

PSK
PSK

Reputation: 17943

Using jQuery you can do this. Check this

http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

Upvotes: 3

Anthony
Anthony

Reputation: 12397

Through javascript you can call form.submit()

Upvotes: 0

Related Questions