• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Drop Downs

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have 2 drop down in the jsp page.
The first drop down is dynamically populated

The second drop down will be populated depending on the selection in the first one.

The second drop down title should be Select XXX Type where XXX is the value selected in the first drop down
I am having the id of the first selected drop down and i am sending the id to the Action Class

How would i get the value of that particular id ?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This one of our most asked question.
Search this, and the HTML forum (Google too) with keywords:
"Dependent dropdown" or "cascading dropdown" and you will find plenty of discussion on the subject.
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Did you find any code related to it. If so, could you please pass the url/ code which would be helpful.
regards
sudha
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this help or you are looking for a struts specific solution ?
Remove - from ev-al
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why the uncessessary use of eval()?

Also this example does not account for the fact that the values in the secondary dropdown depend upon the selected value.
[ October 12, 2007: Message edited by: Bear Bibeault ]
 
Vivek Kr Singh
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True eval is unnecessary ..
Here is a better example

 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Edit: thread hijack removed]
[ October 16, 2007: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
So, your first drop down is being populated by a server call. right. In the Select tag, give the javascript function, like
<Select name="firstDropDown" onChange="displaySecondDropDownList()">
<option ..></option>
in the javascript function,
function displaySeconDropDownList(){
var selectedValue = document.forms[0].firstDropDown.options[selectedIndex].value
then take a hidden variable and assign this value to that variable and set in the corresponding form.
Then invoke the action class, and get the corresponding second dropdown list values from the database based on this selected value. :-)
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi....

i had face the same problem recently........
For this AJAX is the best solution..
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic