I have this form :
<form method='GET' name='search' action='index.php?explore=search'> <input type="hidden" name="searchType" value="all" /> <input class="inputSearchSmall" name="search"> </form> <a href="javascript:document.search.submit()"><img src="img/button_search.png" class="buttonSearch" /></a>
and I'd like to add parameters on the query string, after the action link. So, the result must be:
http://localhost:8080/website/index.php?explore=search&searchType=all&search=example
not :
http://localhost:8080/website/index.php?searchType=all&search=example
what's the best way to do this? Adding a hidden param like :
<input type="hidden" name="explore" value="search" />
Or can I concatenate the parameters to the action script in some way?
The form-data can be sent as URL variables (with method="get" ) or as HTTP post transaction (with method="post" ). Notes on GET: Appends form-data into the URL in name/value pairs. The length of a URL is limited (about 3000 characters)
There are two kinds of HTTP methods, which are GET and POST. The method attribute can be used with the <form> element. Attribute Values: GET: In the GET method, after the submission of the form, the form values will be visible in the address bar of the new browser tab.
Create new elements by means of document. createElement() , and use appendChild() to append each of them to the container.
The method attribute specifies the HTTP method to be used when submitting the form data. The form-data can be sent as URL variables (with method="get" ) or as HTTP post transaction (with method="post" ).
Adding them via a hidden param like you've suggested is the best way to go. It's more maintainable than adding to the form's action attribute value, and will do exactly what your asking. Just make sure you put it within the form tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With