Reputation: 333
I want to submit a simple form, but instead of using a button, I want to do it through a link. Since I'm not using JSF, I cannot use the h:commandLink
component. I do not know how to do it in plain JSP/HTML. Any ideas?
Upvotes: 4
Views: 13816
Reputation: 1108652
There are two ways.
Use CSS to style the button to look like a link.
<input type="submit" value="link" class="link">
with for example
.link {
margin: 0;
border: 0;
background: none;
overflow: visible;
color: blue;
cursor: pointer;
}
Or, use JavaScript to grab the form and submit it.
<form id="formid">
<a href="#" onclick="document.getElementById('formid').submit()">link</a>
</form>
It only won't work in browsers with JS disabled. It's however what JSF h:commandLink
is doing under the covers (JSF components just generates plain HTML/CSS/JS after all, the webbrowser doesn't understand anything else).
Upvotes: 14