I have an intial group of options like these:
<select name="item[type]">
<option value="0" class="dr">First</option>
<option value="1" class="dr">Second</option>
<option value="2" class="dr">Third</option>
<option value="3" class="dr">Fourth</option>
</select>
I want to check if a variable isset($test)
is defined. If it is, then I want to change the option selected where the value
is equal of $test
. Something like this <OPTION SELECTED>
For example. $test = 3
; so, the option selected should be fourth. If $test
is empty or not defined, then the first should be the option that is selected.