Reputation: 722
Let there be a search form with quite many of the input fields. The user may either click:
How do I achieve that? I've only found solutions to make two types of POST request on two separate buttons.
Maybe a JavaScript onclick function to set <form method="??">
right before its submitted? Would that work?
Upvotes: 0
Views: 1691
Reputation: 14279
In HTML5, the <input>
element got some new attributes
<input type="submit" formmethod="post" formaction="save.php" value="Save" />
<input type="submit" formmethod="get" formaction="search.php" value="Search" />
The same attributes are valid for <button>
Upvotes: 6
Reputation: 2111
Yes you can change form method before submit form using jquery
<form method="POST" id="myForm">
<button onclick="changeMethod()">submit</button>
</form>
Function changeMethod in jquery
function changeMethod(){
$("#myForm").attr("method", "get");
}
Upvotes: 0