Html Select Option

engasaar

New Member
I have a list box with options the itemValue is a String and the order in which it is being displayed is inaccurate. I used on the $(document).ready(function(){$("#item").val(1) and set the index position of the item to the first in the list. By default it is set to an option in the list based on alphabetical order, this is not what i want. Using JQuery to set the initial value index i want works, however when i post the page if there are any errors on the page when the page is returned the value of the item in the list goes back to value i set in the document.ready () function. How can i over come this.Code;jquery\[code\]$(document).ready(function(){ $("#skinColorId").val(1);});\[/code\]html:Data is coming from the Database\[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/14074634/colorCode" itemLabel="colorDesc"/></form:select> <form:errors path="skinColorId" class="errors"/><label class="colorPreviewer" id="skinColorPreviewer">color previewer</label></li>\[/code\]Sample of Data:colorId|colorDesc|colorCode155||Select Color||#FFFFFF156||Aqua||#00FFFF157||Aquamarine||#7FFFD4158||Azure||#F0FFFF159||Beige||#F5F5DC160||Bisque||#FFE4C4161||Black||#000000162||BlanchedAlmond||#FFEBCD
 
Back
Top