I have a form with id theForm
which has the following div with a submit button inside:
If your form does not have any id, but it has a class name like theForm, you can use the below statement to submit it:
document.getElementsByClassName("theForm")[0].submit();
<!-- change id attribute to name -->
<form method="post" action="yourUrl" name="theForm">
<button onclick="placeOrder()">Place Order</button>
</form>
function placeOrder () {
document.theForm.submit()
}
Set the name
attribute of your form to "theForm"
and your code will work.
I will leave the way I do to submit the form without using the name
tag inside the form:
<button type="submit" onClick="placeOrder(this.form)">Place Order</button>
function placeOrder(form){
form.submit();
}