views:

36

answers:

0

i have combo box in jsp using Struts2:

select the value of combo box, page is refreshing but after refreshing it display the default value in combo box (first value), not the selected value. how i show the selected value in combox after refreshing.

here is my code on jsp.

Combo box:

<select name="ItemName"  id="ItemName" onchange="ItemCat(this)">
<s:iterator var="items" value="itemsList">
<option  value=" <s:property value="listIndex"/>" <s:if test="listValue==ItemName">selected="true"</s:if>> 
<s:property value="listValue"/></option>
</s:iterator>
</select>


<script type="text/javascript">
function ItemCat(item)  {   
    var items=item.options[item.selectedIndex].text;
    alert('items=='+items);
    var cat = 'display.action?selectedCatItemValue=' + item.options[item.selectedIndex].value;
    alert('cat=='+cat);
    cat= cat+ '&ItemName=' + item.options[item.selectedIndex].text; 
    location.href = cat;
    }</script>