To use the form submit javascript function you need to know the name of the form.
document.forms["myform"].submit();
or
document.myform.submit();
to submit
<form name="myform">...</form>
In my case i have a pletely random name as form name. What I do know is that there is always only one form element present at the page. Any ideas to submit the form using javascript?
<form name="145f88f84584594">...</form>
To use the form submit javascript function you need to know the name of the form.
document.forms["myform"].submit();
or
document.myform.submit();
to submit
<form name="myform">...</form>
In my case i have a pletely random name as form name. What I do know is that there is always only one form element present at the page. Any ideas to submit the form using javascript?
<form name="145f88f84584594">...</form>
Share
Improve this question
asked Oct 22, 2011 at 18:04
Roel VeldhuizenRoel Veldhuizen
4,7339 gold badges45 silver badges79 bronze badges
4 Answers
Reset to default 6document.forms
holds all forms.
This should work: document.forms[0].submit();
.
document.getElementsByTagName("form")[0].submit();
or if you're using jQuery:
$("form:first").submit();
Try: document.getElementsByTagName("form")[0].submit()
You can also just do: 'document.forms[0].submit();'
ps. learning jQuery will be worth the time if you are dealig with dom elements.