I want to be able to submit a form but instead of having to click on a submit button, I'd like to be able to click on an <li>
element and have it submit.
Any help would be GREAT!
Thanks in advance!
Ncoder
The form can be submitted without using submit button by implementing a specific event attribute or by clicking the link. This task can be done by using the OnClick event attribute or by using the form. submit() method in Javascript.
To use the anchor tag as submit button, we need the help of JavaScript. To submit the form, we use JavaScript . submit() function. The function submits the form.
Submit a Form Using JavaScript The most simple way to submit a form without the submit button is to trigger the submit event of a form using JavaScript. In the below example we are going to create a function to submit a form. We will set that function at onclick event of a div tag.
Method 1:Why Dont you use simple css id selector to position your button. Method 2:use webkit box to align horizontally your button. Method 3:you can also make a table with 0 border to position your button.
You could put an onclick event on the LI that calls the forms submit event:
<form id="myForm" action="foo.htm" method="post">
<ul>
<li onclick="myForm.submit();">Click me</li>
</ul>
</form>
Your form would be non-standard and not very accessible though.
<li onclick="formName.submit();">
Although the above method will work, it seems such a strange requirement, and I'd advise re-thinking the logic behind the program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With