12

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

$(function(){

$("input[name=name]").val("somename");
$("input[name=email]").val("[email protected]");
$('#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 !

9
  • Syntax looks correct. Did you try to debug with Firebug? Commented Dec 25, 2009 at 15:33
  • Are you sure your form's id="aweberform" ? Commented Dec 25, 2009 at 15:33
  • Yeap. I purposely hacked the form to carry the id of aweberform Commented Dec 26, 2009 at 2:58
  • Here's the thing, firebug console is totally blank. the name/email field got populated though. its kind of bizarre. Commented Dec 26, 2009 at 2:58
  • I tried using the firebug console and run interavtively by entering this $('#aweberform').submit(); well it returns the following and do nothing then [form#aweberform addlead.pl] Commented Dec 26, 2009 at 3:27

6 Answers 6

13

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

Sign up to request clarification or add additional context in comments.

2 Comments

same problem here , i changed name , submit to other , but when i changed other then page hang , not submitted , and when name="submit" then did not happen anything
alert is working but form not submit if(endTime <= time ) { //alert('123'); $("form").submit(); }
6

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

Comments

3

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

Comments

2

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

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

Comments

2

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

Comments

0

I have tried this and it works:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.