aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes MultiSelect and JavaScript 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 "MultiSelect and JavaScript" Watch "MultiSelect and JavaScript" New topic
Author

MultiSelect and JavaScript

sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
HI
In a multi select box , unless user select option(s) , will it not be possible to send the values back to the server ,in the form of request parameter

For example i have dual multi select box where user can add his selection from one list box to the one on right by clicking on a button or remove [it re-populates the one on left ]
in this scenerio when i access the value of the select box , i dont get any values there unless if its selected

String[] destination= (String[]) request.getParameter("destination");

"destination" is the second list box , it has options but not able to get it like above ,unless those options are selected

Is there any way of achieving this using javascript enumerations

Thanks
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
Yes.. it is actually a round about way, how I achieved this... you can try the same..

On submit, invoke a javascript function, which will iterate through your second multiselect box, and set "selected=true" on all the options. Then you go ahead and do the form.submit()

Thus, on submit, all the values in the second select box would be submitted along with the form, and you can get them as request.getParameterValues()

cheers,
Dawn.
sudharshan tettu
Ranch Hand

Joined: Jul 17, 2006
Posts: 124
Hi thanks for the reply
I am doing it in the same way ,but as you do selected = true they all get selected [i mean they appear to be selected] but
it should not be that way ,is there any way
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
Another way, is to create a hidden field, and again, just before submitting the form, iterate through your second multiselect box, and add the option values to this hidden field [comma separated or something like that], without actually selecting any of the options - and then submit the form. In server side, you can get the value of the hidden field, and hence know what are the options in that second box.

By the way, just curious, what is stopping you from using the first solution?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MultiSelect and JavaScript