This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Struts and the fly likes Passing a collection to javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing a collection to javascript" Watch "Passing a collection to javascript" New topic
Author

Passing a collection to javascript

Anjali Naveen
Greenhorn

Joined: Jun 28, 2005
Posts: 15
Problem:

I have a drop down of items and on the click of a particular item i want the amount of the item displayed on a text box.
I have retireved a list of items (Each Item has a id, name and amount). I have also displayed the items in a drop down. My problem is populating a text field with the amount of the item that has been selected.

td><html:select property="selectedFee" >
<html ption value="0" >Select One</html ption>
<html ptions collection="itemList" property="itemId"labelProperty="itemName"></html ptions>
</html:select>
<td>
<mifos:mifosalphanumtext property="itemAmount"/>
</td>
</tr>
</c:forEach>
I want itemAmount displayed with the amount only when some item from the drop down is selected. CAn i pass the itemList(collection containing Item objects) to a javascript funtion adn iterate through it.
Plz plz help!!
Jason Moors
Greenhorn

Joined: Nov 01, 2005
Posts: 4
What you can do is create a Javascript array of the values dynamically via a scriptlet, or custom tag from your collection.

Then create a Javascript function that is called select onChange event, add set the value in the itemAmount box.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a collection to javascript
 
Similar Threads
Regarding html:select kind of URGENT
After validation drop down box values will be lost.
whats problem with following code ** urgent
Passing a collection to javascript
dynamic data arranged in alphabetical order in html:select and html:options