Reputation: 4038
I want to submit the form without using submit button form looks like
<form method="post" action="action.php">
// somany divs
<input type="hidden" name="ivlue" value="er">
</form>
<script>
$(function(){
$("form").trigger("submit");
})
</script>
and also tried
$("form").submit();
But this code doesn't submit the form.
Upvotes: 0
Views: 3720
Reputation: 1961
If you want to submit you can use this code which is not using jquery, it is the plain js function
document.forms["formname"].submit();
And you need to have a form, which you identify with an id attribute in the form tag
<form id='formname' action='mypage.html'>
Upvotes: 1
Reputation: 22158
$(document).ready(function(){
$("form").trigger("submit");
});
$('form').on('submit', function() { alert("ya"); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<form method="post" action="action.php">
// somany divs
<input type="hidden" name="ivlue" value="er">
<input type="submit" style="display:none">
</form>
In firefox you need the submit button. You can hide it, but needs to be present.
Upvotes: 3