Rob Chuah
Rob Chuah

Reputation: 251

using Jquery to automatically submit form

I am trying to submit a form by using jquery automatically after page load

$(function(){

$("input[name=name]").val("somename");
$("input[name=email]").val("323@ds.com");
$('#aweberform').submit();

});

Both the name/email value can be seen to get populated on the form. But the submit event wont triggered.

Any one here that can shed any lights ?

thanks !

Upvotes: 12

Views: 57958

Answers (6)

Debraj Chatterjee
Debraj Chatterjee

Reputation: 33

I have tried this and it works:

window.onload = function () {
    document.forms['form_id'].submit();
};

Upvotes: 0

Hugh Seagraves
Hugh Seagraves

Reputation: 594

I had to remove my Submit button to get $('#myForm').submit() to work. Not sure why.

Upvotes: 3

Isaac Bruno
Isaac Bruno

Reputation: 58

Try this document.getElementById('formId').submit();

Upvotes: 2

atpatil11
atpatil11

Reputation: 433

Try this $('#aweberform').submit();

Upvotes: 6

Rob Chuah
Rob Chuah

Reputation: 251

ok i found out the problem

apparently the submit input cannot have the name submit

<input type="submit" name="submit" value="click to submit!">

changed to

<input type="submit" name="someothername" value="click to submit!">

and that got the problem fixed

Upvotes: 13

Philip Schlump
Philip Schlump

Reputation: 3144

Add a function in the submit. Seems to work for me.

$('#aweberform').submit(function(){return true;});

Upvotes: 2

Related Questions