Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

list box problem

 
thejaswi mogenahalli
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic