• Post Reply Bookmark Topic Watch Topic
  • New Topic

All the values of a dropdown  RSS feed

 
Vineeth Vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I get all the values of a dropdown on form submission.

If I do request.getParameter("dropdown") , I get just the selected. How do I get all the values?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. That's not how a dropdown works. You can make the select element a multi-select list with the multiple attribute, but you will still only get the selected values.

Why are you using a select element if that's not what you need?
 
Vineeth Vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am populating the dropdown value using Ajax and each time the dropdown values are different. I need to repopulate the dropdown after form submission based on what was there before the form submitted.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That doesn't sound like the best way to go about it.

Exactly why do you need all the unselected values to know how to determine what the new values should be?
 
Vineeth Vasudevan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I was not clear earlier, let me rephrase a bit

I have 4 dropdowns. 3 of of them are disabled on page load. When user selects a value in first dropdown an ajax call is fired which helps in populating the other 3 drop downs.

After making the selections, the user submits the form. Now, the next time the page loads. I need to show the previously selected values of the dropdown and ALSO all the values. The only way I can think of achieving this is using sessions, any other ways?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why aren't you submitting the form via Ajax so that you don't need to worry about page reloads?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!