How can I submit a form using JavaScript?
You can use...
document.getElementById('theForm').submit();
...but don't replace the innerHTML
. You could hide the form and then insert a processing... span
which will appear in its place.
var form = document.getElementById('theForm');
form.style.display = 'none';
var processing = document.createElement('span');
processing.appendChild(document.createTextNode('processing ...'));
form.parentNode.insertBefore(processing, form);
It works perfectly in my case.
document.getElementById("form1").submit();
Also, you can use it in a function as below:
function formSubmit()
{
document.getElementById("form1").submit();
}
Set the name
attribute of your form to "theForm"
and your code will work.