aspose file tools*
The moose likes Struts and the fly likes create a dropdown list based on selection from another dropdown list in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "create a dropdown list based on selection from another dropdown list in jsp" Watch "create a dropdown list based on selection from another dropdown list in jsp" New topic
Author

create a dropdown list based on selection from another dropdown list in jsp

Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 96

Hi,

I am working with struts framework using jsp. I have 2 drop down lists in my jsp. Based on the selected value in the first drop down list i need to enable the second drop down list with some options. The options in both the drop down list are directly hard coded in jsp. Not retrieving from database. Please help.

Dropdown1
------------


After Selecting the value in dropdown1 i need to enable dropdown2

Dropdown2
-------------


jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Vidya,

Nutting to do with the struts. Refer this thread. Its more related to javascript.

Jatan
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 96

Thanks for the reply. But jatan i want to do this in struts .
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi vidya,

AS you have mentioned that
The options in both the drop down list are directly hard coded in jsp
you have the static values so as par my view it is similar to the javascript and same approach will be applied.

If you are fetching value of the second drop down from the database then you need to submit the form with onchange event and need to fetch the value.

Jatan
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 96
Ok Jatan, The code you provided is working fine.. but in my jsp i want to use struts taglibraries like html. But i can not use struts html tag libraby in this code..
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Vidya,

What is the error you are getting? Post some code so i might be able to help you..
The right way to learn the things is to try the best of your self then you should look for the help. Hope you will do the enough home work and then send the quiries.

We are here to help.

Regards
Jatan
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 96




Hi Jatan i tried the above caode.. It is working fine.. But the above code in plain html. But i need to use the html tag library in sruts. That means in the above code i need to use the tags as,

<html>
<html:form>
<html:select> like that.. But with the above code i cannot use html tag library.

In the above code <form> tag contains attribute like "name". But in html tag library there is no name attribute for html:form
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Vidya,

1) Too use struts tag library you need to add tld files like you add the jar files.
2)you need to put the entry in web.xml for the struts tag library .
3)you need to import it in jsp file with the tag @taglib prefix and uri.

but for all these you need to search on google.

Regards
Jatan
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 96

HI Jatan,

I know how to use struts tag library.. I used it so many times in my project. But i am unable to explain my problem. That's ok i will try my level best. Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create a dropdown list based on selection from another dropdown list in jsp
 
Similar Threads
dynamic value to be submitted to form beans
Ajax-Struts
Drop down without scrollbar
Need help selected text fields visible for particular option from drop down list in JSP(struts)
Displaying Data From Different Tables in .jsp