File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Dynamic values in Multi Select Box when value in Combo box changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dynamic values in Multi Select Box when value in Combo box changes" Watch "Dynamic values in Multi Select Box when value in Combo box changes" New topic
Author

Dynamic values in Multi Select Box when value in Combo box changes

Pratik Lohia
Ranch Hand

Joined: May 05, 2005
Posts: 88
Hi
I have a Multi Select box, the values in which are dependent on the values in a select box. e.g if i select a value 'x' in the combo box, the Multi select box(MSB) will have all the values having Id as 'x'. Now if I change the value in the combo box to 'y' the values in the MSB should now be the ones that have Id as 'y'. All this needs to be done using javascript on the client side.

Snippet of the MSB code... I am using Struts 1.1 tags



[edit remove all of the extra space causing major scroll issues - eric]
[ February 28, 2006: Message edited by: Eric Pascarello ]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well you would have to something like this:

http://www.javascriptkit.com/script/cut183.shtml

Eric
Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
is there a way to use this but the values to be populated should be dynamic and not static? i mean, is there a way to retrieve records from the database in javascript?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Originally posted by shuini gustav:
is there a way to retrieve records from the database in javascript?


No.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
well then isn't there a way around that?
like i could retrieve from the database using jsp place it in an array and then pass the array to javascript?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You need to make a request to the server to get the values. You are going to have to do it through a post back or the popular Ajax request.

Eric
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dynamic values in Multi Select Box when value in Combo box changes