Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I submit a form with a <li> instead of a submit button?

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

like image 336
NCoder Avatar asked Jan 31 '11 16:01

NCoder


People also ask

How can we submit a form without submit button?

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.

Can I use a tag as submit button?

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.

How do I automatically submit a form without clicking?

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.

How do I change the submit button position?

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.


2 Answers

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.

like image 110
alergy Avatar answered Sep 24 '22 14:09

alergy


<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.

like image 45
Greg Avatar answered Sep 23 '22 14:09

Greg