How to submit a form without clicking a submit button?
Answers (1)
Add AnswerWith accessing the tag name you can use the .submit() method of javaScript for it .
Let’s say you have one form where you use div instead of submit button.
<form id="form1" action="" method="POST"> <div onClick="submitForm()"></div> </form >
Now There Are Two Ways You Can Do This
Sol 1:: By TagName ;
document.getElementsByTagName('form')[0].submit()
Sol 2 : By Id
<code> <script> function submitForm(){ var form = document.getElementById("form1"); form.submit(); alert("Form Submitted"); } </script></code>
Whenever user click on div form get sumitted