Skip to content

Instantly share code, notes, and snippets.

@stekhn
Created May 27, 2017 15:24
Show Gist options
  • Save stekhn/d2b6ffe8693d178981aa59d702c048ce to your computer and use it in GitHub Desktop.
Save stekhn/d2b6ffe8693d178981aa59d702c048ce to your computer and use it in GitHub Desktop.
Change URL location and parameters with a simple a HTML form. The query strings gets constructed on form submit. No JavaScript required.
<form action="search">
<fieldset>
<legend>Search string</legend>
<input type="search" name="query" value="" placeholder="Enter text">
</fieldset>
<fieldset>
<legend>Search for</legend>
<input type="radio" name="type" value="name" checked="checked">
<label>Name</label>
<input type="radio" name="type" value="address">
<label>Address</label>
<input type="radio" name="type" value="email">
<label>E-mail</label>
</fieldset>
<fieldset>
<legend>Sort by</legend>
<input type="radio" name="sorting" value="relevance" checked="checked">
<label>Relevance</label>
<input type="radio" name="sorting" value="date">
<label>Date</label>
</fieldset>
<fieldset>
<legend>Submit your search</legend>
<input type="submit" value="Search">
</fieldset>
</form>
<p>See how the query parameters in the URL get changed. Example: <pre>http://localhost/search?query=Markus&type=name&sorting=relevance</pre></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment