Karem
Karem

Reputation: 18103

HTML: Making a link, submit in form?

I really want to have a link, such as, "Save" that act the same way as a input type submit button?

I never figured out how to do this, is it even possible? How?

Upvotes: 5

Views: 10878

Answers (3)

Stephan Muller
Stephan Muller

Reputation: 27600

Random example:

Form:

<form id="myform" name="myform" method="post" action="something.php">

Submit link: <a href="javascript:postform()">Click!</a>

JavaScript:

<script language="JavaScript" type="text/javascript">
function postform( )
{
  document.getElementById('myform').submit() ;
}
</script>

Upvotes: 2

The Surrican
The Surrican

Reputation: 29856

its possible using javascript. like this:

<form name="theform" ...>
<a href="javascript:document.theForm.submit();">Save</a>
</form>

but i would suggest to style a button to look as a link, so you have no problem with clients without javascript

Upvotes: 2

user151323
user151323

Reputation:

You can just style the button to look like a link:

input[type="submit"]
{
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
}

Upvotes: 8

Related Questions