wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 60046
    
  65

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting elements from a list box
 
Similar Threads
Downloading multiple files in one request
Listing and Action Form Validation
drop down box using struts
Multiselect list box
Inline Form Validation