• 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

list box problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends
I am new to this forum.
I am problem with my project

in this page i have two list boxes. I have populate the second list box based of the value selected in the first listbox.


<html:select styleClass="input" property="worklevel"
<html ptions name="levelCodes" labelName="levelCodes">
</html ptions>
</html:select>

this is first list box .it is populating itself using a list varible called levelcodes in session.

<html:select styleClass="input" property="dependentlevel">
<html ptions name="dependentlevel" labelName="dependentlevel">
</html ptions>
</html:select>

please help me with this.
i have no idea how to do it.

thanks in advance.
Thejaswi
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I see it, there are 3 ways to handle this. All three of them require the use of javaScript, So if you don't know much about javaScript, I'd suggest you spend some time learning it.

1- Call a function from the onchange event of the first dropdown box to submit the form and cause the action on the server side to read the value of the first dropdown box and populate the values for the 2nd. Then, using the onload event of the <body> tag, you can cause the focus to be placed on the 2nd dropdown box when the page is refreshed. If you use this method you'll need to set some type of flag to indicate whether you're intending to submit the entire form for processing, or only refreshing the 2nd dropdown box.

2- If there are only a few sets of possible options for dropdown box 2, you can create javascript arrays for each of the option sets. Then, use the onchange event of the first dropdown to swap out the options for the 2nd dropdown based on what was selected in the first.

3- Use an AJAX call to the server in the onchange event of the first dropdown box to determine the contents of the 2nd dropdown box.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic