Boris Kozarac Boris Kozarac - 6 months ago 15
HTML Question

Don't send default selected option value

I am creating a custom search form and I have this code with first option

<select name="something">
<option selected>Choose</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>

<select name="something2">
<option selected>Choose</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>


This is what I get in url if I select only something from second select options.

?s=&something=ChooseB&something2=B


Is it possible for form to not send this "Choose" value? Can it be done using Html or do I have to use Jquery? I am doing this in Wordpress if it matters.

Answer

Try This:

<select name="something">
<option value="">Choose</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>

<select name="something2">
<option value="">Choose</option>
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>