I'm trying to submit a form with JavaScript but I get the following error:
TypeError: 'undefined' is not a function (evaluating 'form.submit()')
This is the relevant code:
var form = document.getElementById("form"),
submit = document.getElementById("submit");
submit.addEventListener("click", function (e) {
e.preventDefault();
form.submit();
}, false);
Edit: this is the relevant html code:
<form method="post" action="www.example.com" id="form">
<input type="submit" id="submit">
</form>
Thanks for your help!