• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MultiSelect and JavaScript

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic