Use a normal link to submit a form

Upvote picture Upvote · Nov 26, 2010 · Viewed 288.5k times · Source

I want to submit a form. But I am not going the basic way of using a input button with submit type but a a link.

The image below shows why. I am using image links to save/submit the form. Because I have standart css markup for image links I don't want to use input submit buttons.

I tried to apply onClick="document.formName.submit()" to the a element but I would prefer a html method.

alt text

Any ideas?

Answer

Jan Sverre picture Jan Sverre · Nov 26, 2010

Two ways. Either create a button and style it so it looks like a link with css, or create a link and use onclick="this.closest('form').submit();return false;".