Search code examples
jqueryhtmlcsselrte

How can I use javascript to submit a form that is in another location of the page?


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.


Solution

  • Try next code

    document.forms['post'].submit();