Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic