How can I submit a POST form using the <a href= "https://stackoverflow.com/..." rel="nofollow noreferrer"> tag?
How do I submit a POST form to showMessage.jsp using the <a href="..."> tag?
<form action="showMessage.jsp" method="post"> <a href="showMessage.jsp"><%=n%></a> <input type="hidden" name="mess" value=<%=n%>/> </form> No JavaScript needed if you use the button:
<form action="your_url" method="post"> <button type="submit" name="your_name" value="your_value" class="btn-link">Go</button> </form> You can style the buttons to look like a link , for example:
.btn-link{ border:none; outline:none; background:none; cursor:pointer; color:#0000EE; padding:0; text-decoration:underline; font-family:inherit; font-size:inherit; } You need to use the Javascript submit function on your form object. Look in other features .
<form action="showMessage.jsp" method="post"> <a href="javascript:;" onclick="parentNode.submit();"><%=n%></a> <input type="hidden" name="mess" value=<%=n%>/> </form> For this you need to use javascript.
<form id="form1" action="showMessage.jsp" method="post"> <a href="javascript:;" onclick="document.getElementById('form1').submit();"><%=n%></a> <input type="hidden" name="mess" value=<%=n%>/> </form> If you use MVC to execute it, you will need to do something like this
<form action="/ControllerName/ActionName" method="post"> <a href="javascript:;" onclick="parentNode.submit();"><%=n%></a> <input type="hidden" name="mess" value=<%=n%>/> </form> I just looked through a few examples here and did not see that MVC decided that it would not hurt to publish it.
Then in your Action in the controller, I just put <HTTPPost> top. I believe that if you do not have <HTTPGET> , then it will still work, but explicitly putting it there is a little better.
There really is no way to cheat <a href= .. in the POST method. However, given that you have access to the CSS of the page, this can be replaced using the form.
Unfortunately, the obvious way to simply style a button in CSS as an anchor tag is not compatible with a cross browser, as different browsers treat <button value= ... differently.
Incorrect: <form action='actbusy.php' method='post'> <button type='submit' name='parameter' value='One'>Two</button> </form> In the above example, the “Two” and “Transmit”: one ”options will be displayed in FireFox, while it will display“ One ”and will also pass the“: one ”option in IE8.
The method is to use hidden input fields for data delivery and buttons for sending it.
<form action='actbusy.php' method='post'> <input class=hidden name='parameter' value='blaah'> <button type='submit' name='delete' value='Delete'>Delete</button> </form> Note that this method has a side effect, which in addition to the: blaah parameter will also deliver "delete: Delete" as redundant parameters in the POST.
You want to keep the value attribute for the button and the button label between the tags the same ("Delete" in this case), because (as indicated above) some browsers will display one, and some will display the other as a button label.