wood burning stoves 2.0*
The moose likes Struts and the fly likes how to get both value and text of selected item in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to get both value and text of selected item in action class" Watch "how to get both value and text of selected item in action class" New topic
Author

how to get both value and text of selected item in action class

Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
I am using struts 1.1 and the problem relates to dropdown selected item text.
My jsp has a select list as follows:
<html:select styleId="state" property="state" onchange="loadList('state', 'districtCell', 'district')">
<c:forEach var="thisState" items="${stateMap}">
<htmlption value="${thisState.key}">${thisState.value}</htmlption>
</c:forEach>
</html:select>

where stateMap is a hash map
There are other such lists with
<option value="${city_id}">${cityName}</option>

When the form is submitted, I want the action class to be able to access the value of the selected item in the list(which it is doing) and
the text of the selected item also(which I do not know how to do.)

The form bean has getter setter methods for each list, but only the value seems to be submitted.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get both value and text of selected item in action class
 
Similar Threads
dynamic value to be submitted to form beans
LinkedHashMap Iteration problems
Getting an exception while trying to check the radio button
Help me with Struts HTML tags
DynaValidatorActionForm not working