using Jquery to automatically submit form

2020-07-04 15:29发布

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 !

5条回答
老娘就宠你
2楼-- · 2020-07-04 15:45

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

查看更多
Viruses.
3楼-- · 2020-07-04 15:46

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

查看更多
Luminary・发光体
4楼-- · 2020-07-04 15:54

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

查看更多
可以哭但决不认输i
5楼-- · 2020-07-04 15:59

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

查看更多
贪生不怕死
6楼-- · 2020-07-04 16:01

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

$('#aweberform').submit(function(){return true;});
查看更多
登录 后发表回答