This is purely an HTML issue. The problem is that you’ve tried to indicate the selected item by setting a value=""
attribute on the <select>
element. That’s not how <select>
works.
To mark an option as selected by default the <option>
tag needs to be given the selected
attribute.
For example, you are outputting this:
<select id="j_applicationCategory" name="j_applicationCategory" value="UtilitiesApplication" style="width: 100%" />
<option value="GameApplication">GameApplication</option>
<option value="UtilitiesApplication">UtilitiesApplication</option>
<option value="DesignApplication">DesignApplication</option>
<option value="ReferenceApplication">ReferenceApplication</option>
</select>
You need to output this:
<select id="j_applicationCategory" name="j_applicationCategory" style="width: 100%">
<option value="GameApplication">GameApplication</option>
<option value="UtilitiesApplication" selected>UtilitiesApplication</option>
<option value="DesignApplication">DesignApplication</option>
<option value="ReferenceApplication">ReferenceApplication</option>
</select>
Also note that I have removed an inappropriate closing /
from the select tag.
WordPress has a utility function, selected()
, that makes outputting this attribute based on the current value easier:
echo '<select id="j_applicationCategory" name="j_applicationCategory" style="width: 100%">';
echo '<option value="GameApplication" ' . selected( $j_applicationCategory, 'GameApplication', false ) . '>GameApplication</option>';
echo '<option value="UtilitiesApplication" ' . selected( $j_applicationCategory, 'UtilitiesApplication', false ) . '>UtilitiesApplication</option>';
echo '<option value="DesignApplication" ' . selected( $j_applicationCategory, 'DesignApplication', false ) . '>DesignApplication</option>';
echo '<option value="ReferenceApplication" ' . selected( $j_applicationCategory, 'ReferenceApplication', false ) . '>ReferenceApplication</option>';
echo '</select>';