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 Getting elements from a list box 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 "Getting elements from a list box" Watch "Getting elements from a list box" New topic
Author

Getting elements from a list box

naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

I have a form which the user enter some data into text fields and submit the form. After submitting I have a jsp page where I have use some beans and I save the objects into database.

Now I have insert the following mechanism(in Javascript):
I have 2 list box.The first one contains all the subjects.If the user select one subject and click on the button add the subject is remove and added to the other list box(let called it Prerequisite).
Now how can I get that values from the "Prerequisite" list box and save them. With request.getParameter surely you can't

I hope you understand me what I'm trying to do...
Any help?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Two approaches come to mind:

1) In the form's submit handler, cause all the list's elements to be selected. That way, they'll all be submitted as the list's value. Be sure that the list is set to be multiple.

2) In the form's submit handler, create hidden elements for each entry in the list.

Approach (1) is probably easier, but the 'flash' as the list elements are selected just before submission could be annoying.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting elements from a list box