This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes list box problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "list box problem" Watch "list box problem" New topic
Author

list box problem

thejaswi mogenahalli
Greenhorn

Joined: Mar 20, 2006
Posts: 1
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

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: list box problem