aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Handling dynamic select boxes on client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Handling dynamic select boxes on client side" Watch "Handling dynamic select boxes on client side" New topic
Author

Handling dynamic select boxes on client side

Swapna Omprakash
Greenhorn

Joined: Dec 19, 2007
Posts: 3
Hi,

I have a hashmap that has values in key value pairs
(key1 -> a1,a2,a3)
(key2 -> b2,b3,b7)
...
All the keys are displayed in the first select box.What I want to do here is,
when a particular key is selected the corresponding values have to be populated in the second select box.
All this has to be done on the jsp page before doing a form submit.
The hashmap values are pre-determined and available to use in the JSP.

How can I iterate this hashmap in JavaScript and how can I display the correponding values in the second select box when a key is selected in the first select box.
Can anyone help me to do this ?

Thanks for your respone,

Swapna.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"swapna",
Welcome to JavaRanch!

We're pleased to have you here with us here on the ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. You can change it here
[ December 19, 2007: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You either need to spit out all of the values into the page when rendering in a way JavaScript can understand them or you need to look into Ajax.

Eric
Swapna Omprakash
Greenhorn

Joined: Dec 19, 2007
Posts: 3
Thanks Eric for your quick reply.
I am evaluating about using javascript for this purpose as I have only limited values which I need to display in the select boxes.
I have the values to be displayed available in a 2 dimentional arraylist in the jsp.
How can I make my values present in JSP in request scope available to the JavaScript for it to iterate through?


Thanks for your reply.
Swapna.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

Originally posted by Swapna Omprakash:
How can I make my values present in JSP in request scope available to the JavaScript for it to iterate through?.
You cannot make them directly available. Rather, you use the JSP to write a JavaScript construct, such as an array, that contains the data.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling dynamic select boxes on client side