如何使用 <a href="..."> 提交 POST 表单?标签? [英] How can I submit a POST form using the <a href="..."> tag?

查看:28
本文介绍了如何使用 <a href="..."> 提交 POST 表单?标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何仅使用 <a href="..."> 标记将 POST 表单提交到 showMessage.jsp?

How can I submit a POST form to showMessage.jsp using just the <a href="..."> tag?

<form action="showMessage.jsp" method="post">
    <a href="showMessage.jsp"><%=n%></a>
    <input type="hidden" name="mess" value=<%=n%>/>
</form>

推荐答案

如果您使用按钮代替,则不需要 JavaScript:

No JavaScript needed if you use a button instead:

<form action="your_url" method="post">
    <button type="submit" name="your_name" value="your_value" class="btn-link">Go</button>
</form>

您可以将按钮设置为链接的样式,例如:

.btn-link {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
    color: #0000EE;
    padding: 0;
    text-decoration: underline;
    font-family: inherit;
    font-size: inherit;
}

这篇关于如何使用 &lt;a href="..."&gt; 提交 POST 表单?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆