HTML List Box not displaying correct selected option

UkrPost

New Member
I have a query that selects a list of colors from a table. The select statement is \[code\]SELECT ColorDesc, ColorCode FROM Colors ORDER BY ColorCode\[/code\].A sample of the data in the table is:\[code\]ColorDesc, ColorCodeSelect Color -#0Black -#000000Navy -#000080DarkBlue -#00008BMediumBlue -#0000CDBlue -#0000FFDarkGreen -#006400...\[/code\]When the list is returned the listbox returns the correct options however the display option is defaulted to 'Black' when it should be 'Select Color'.Resulting HTML (updated 2012.12.26):\[code\]<label for="skinColorId">Select Skin Color</label> <select id="skinColorId" name="skinColorId" title="Select Skin Color"> <option value="http://stackoverflow.com/questions/14048566/#000000" selected="selected">Select Color</option><option value="http://stackoverflow.com/questions/14048566/#00FFFF">Aqua</option><option value="http://stackoverflow.com/questions/14048566/#7FFFD4">Aquamarine</option><option value="http://stackoverflow.com/questions/14048566/#F0FFFF">Azure</option><option value="http://stackoverflow.com/questions/14048566/#F5F5DC">Beige</option><option value="http://stackoverflow.com/questions/14048566/#FFE4C4">Bisque</option><option value="http://stackoverflow.com/questions/14048566/#000000" selected="selected">Black</option><option value="http://stackoverflow.com/questions/14048566/#FFEBCD">BlanchedAlmond</option><option value="http://stackoverflow.com/questions/14048566/#0000FF">Blue</option><option value="http://stackoverflow.com/questions/14048566/#8A2BE2">BlueViolet</option><option value="http://stackoverflow.com/questions/14048566/#A52A2A">Brown</option><option value="http://stackoverflow.com/questions/14048566/#DEB887">BurlyWood</option><option value="http://stackoverflow.com/questions/14048566/#5F9EA0">CadetBlue</option><option value="http://stackoverflow.com/questions/14048566/#7FFF00">Chartreuse</option><option \[/code\]JSP Code (updated 2012.12.26):\[code\]<li><form:label for="skinColorId" path="skinColorId">Select Skin Color</form:label> <form:select path="skinColorId" id="skinColorId" title="Select Skin Color"> <form:options items = "${skinColor.skinColorList}" itemValue="http://stackoverflow.com/questions/14048566/colorCode" itemLabel="colorDesc"/> </form:select> <form:errors path="skinColorId" class="errors"/><label class="colorPreviewer" id="skinColorPreviewer">color previewer</label></li>\[/code\]
 
Back
Top