Reputation:
Let's say I have this form in my page
<form id="myform" action="src/post.php" name="post" method="post" target="_blank">
<div id="editor"></div>
</form>
Which works flawlessly. But I need to use a button from another location in the same file to submit that form by ID. It's like a trigger command, but I believe it can only be achieved by Javascript.
Upvotes: 0
Views: 100
Reputation:
I could make it work, but it seems that when I submit the form from another location it is not including the <div id="editor">
that is withing the form and that's why I'm getting a blank page.
Upvotes: 0
Reputation: 68400
Assuming you have a button with id submitButton
, this should do the trick
<button id="submitButton">Submit</button>
You could do
$('#submitButton').on('click', function() {
$('form').submit();
});
Upvotes: 0