Reputation: 2219
I want to be able to submit a form after a page loads automatically through Javascript.
I am writing a google chrome extension.
So far the extension can fill in text in the input boxes but I can't figure out a way to get to the next step where the user would click Submit. Please help. Thank you.
EDIT: Pardon my edit. It wasn't clear that he was writing a chrome extension to those of us in the chatroom. --drachenstern
Upvotes: 6
Views: 19932
Reputation: 25164
Did you try something like document.getElementById('myForm').submit()
?
With a form like (after EDIT):
<form id="myform" action="/url/To/Action">
...
</form>
...
<script>
document.getElementById('myForm').submit();
</script>
EDIT after your comment:
The script
tag must be after the form
tag. Or at the very end of the body
tag if you want to be sure all the DOM elements are loaded.
Upvotes: 8