Form submission with a ?key=val query string already in the action attribute ignores that query string
I know this is an old question, but the solution is actually pretty simple (and neat!).
All you have to do is sending the querystring with hidden input fields in the format name="key"
and value="value"
.
?brandcode=JM&t=cat_items would "translate" into:
<input type="hidden" name="brandcode" value="JM" />
<input type="hidden" name="t" value="cat_items" />
Completely remove the querystring from your action
.
Query string lost from a submit button
The problem is with the form:
<form name="helloButton" action="hello?id=100" method="get">
<input type="submit" value="Hello">
</form>
As the form method is set to get, it's changing the query string. method="get"
tells the browser to add the contents of the form to the query string which means the current query string gets removed.
You can add the ID as a hidden field in the form like this:
<form name="helloButton" action="hello" method="get">
<input type="hidden" name="id" value="100">
<input type="submit" value="Hello">
</form>
That will tell the browser to add the hidden field to the query string resulting in hello?id=100
. Alternatively you could change the form method to POST.
How to remove 'GET?' string from URL when submitting a GET form
You specified this as , this is the URL where the form will submit to, you should specify action="GET"
method="GET"
, or just nothing, since that is the default method, so:
<section id="brand-list">
<form method="GET">
<input type="text" name="keyword">
<button>Search</button>
</form>
</section>
GET form action with URL parameter gets removed on form submission
When you use method="get"
, you can't put values in the query string of the action
. They will be replaced by the values from the form fields when you post the form.
Put the values in hidden fields instead:
<form method="GET" action="a.php">
<input type="hidden" name="r" value="1">
<input type="radio" name="go" value="1">
</form>
POST forms: How to put GET parameters in action attribute?
If you absolutely need to put it on action attribute you can use method="POST"
.
<!DOCTYPE html>
<html>
<body>
<form action="draft.html?test=1" method="POST">
<button type="submit">Valid</button>
</form>
</body>
</html>
Otherwise if you want to send your data trough GET
use
<!DOCTYPE html>
<html>
<body>
<form action="draft.html" method="GET">
<input type="hidden" name="test" value="1">
<button type="submit">Valid</button>
</form>
</body>
</html>
PHP form action is not working and is not updating querystring
Your form is overriding the query string parameters in your action attribute.
Instead of putting the query string in the action, add a hidden field
<form class="filter_form" method="get" action="index.php">
<!-- ... the rest of your form code -->
<input class="button filter_button" type="submit" value="filter" />
<input type="hidden" name="page" id="page" value="agenda" />
</form>
Related post: submitting a GET form with query string params and hidden params disappear
Form doesn't take me to action url when submitting
You almost have it. All you need to do is to move the "action" and "method" attributes into the form tag instead of the div.
Since you don't have the "action" in the form tag, the default behavior is to submit the form to the same page.
Related Topics
Angular2, What Is the Correct Way to Disable an Anchor Element
Html5 Input Type Date Format to Mm/Dd/Yyyy Causing Issue in Chrome
Why Don't Flex Items Shrink Past Content Size
How to Vertically Align Elements in a Div
Change Default Text in Input Type="File"
Make a Div Fill the Height of the Remaining Screen Space
Why Not Use Tables For Layout in Html
What to Do Regular Expression Pattern Doesn't Match Anywhere in String
What Does Enctype='Multipart/Form-Data' Mean
How to Modify the Primeng P-Calendar Style
How to Rotate the Block Every Time You Click on the Button
How to Toggle Mat-Expansion-Panel With Button Click
A Div With Auto Resize When Changing Window Width\Height
How to Get the Client Ip Address from Browser in Angular (Typescript)
Angular 5 File Upload: Failed to Set the 'Value' Property on 'Htmlinputelement'
How to Download a Locally Stored File in Vuejs
How to Set Max-Length in an Html5 "Input Type=Number" Element
How to Prevent VS Code from Breaking Up Long HTML Lines into Multiple Lines