<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).
Since wordpress already uses jquery you can try something like this:
Js only solution:
or if you are using jquery you can replace
with:
To avoid many if-else structures, let javascript do the trick automatically: