<form method="get" action="">
<select name="name">
<option value="a">a</option>
<option value="b">b</option>
</select>
<select name="location">
<option value="x">x</option>
<option value="y">y</option>
</select>
<input type="submit" value="Submit" class="submit" />
</form>
On submitting the form, how do I make sure that the selected values remain selected in the dropdowns? This form is inside wordpress (PHP).
After trying al this "solves" nothing work. Did some research on w3school before and remember there was explanation of keeping values about radio. But it also works for Select option. See here an example. Just try it out and play with it.
If you are using Wordpress (as is the case with the OP), you can use the
selected
function.I don't work in WP much but for forms outside of Wordpress, this works well.
PHP
HTML
This works for me!
Try this solution for keep selected value in dropdown: