I am trying to do something, but I don't know if it's acutally possible...
Basically I'm trying to pass information in the url... (something like this)
<form method="GET" action="">
<input name="q" placeholder="Browse Topics" />
</form>
but instead of using a text input I would like the user to simply click an option in a dropdown menu... (like this)
<form action="" method="GET">
<div >
<label for="units">Units:</label>
<select name="units" id="units-selection">
<option value="metric">Metric</option>
<option value="imperial">Imperial</option>
</select>
</div>
<div >
<label for="language">Language:</label>
<select name="language" id="language-selection">
<option value="english">English</option>
<option value="italian">Italian</option>
</option>
</select>
</div>
</form>
Is it possible to do so? Hopefully I've explained myself decently lol
CodePudding user response:
You can do this with javascript and onchange attribute:
<div >
<label for="units">Units:</label>
<select name="units" id="units-selection" onchange="window.location.href='?units=' units-selection.value '&language=' language-selection.value">
<option value="metric">Metric</option>
<option value="imperial">Imperial</option>
</select>
</div>
<div >
<label for="language">Language:</label>
<select name="language" id="language-selection" onchange="window.location.href='?units=' units-selection.value '&language=' language-selection.value">
<option value="english">English</option>
<option value="italian">Italian</option>
</option>
</select>
</div>