aspose file tools*
The moose likes JSP and the fly likes How Can Implement acascading dropdown list in jsp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How Can Implement acascading dropdown list in jsp?" Watch "How Can Implement acascading dropdown list in jsp?" New topic
Author

How Can Implement acascading dropdown list in jsp?

Diparnab Dey
Greenhorn

Joined: Aug 02, 2013
Posts: 3
i have a jsp file where there is two dropdown lists...
one is category one is topic. one will select a category from the first drop down list and then the topics which belongs to the selected category will be shown in the second drop down list.( both the values will be retrieved from the database)
i am thinkig in this way.... i will send the selected value of the category from the jsp file to a DAO class , create a method there which will retrieve the topics which belongs to the selected quearies in the resultset. and then in the first jsp i will create an object of the DAO class and retrive the resultset via an arrayList..
this is the first checkbox in StartDiscussion.jsp
<select name="category" onchange="">
<%
CategoryInfoDao catdao = new CategoryInfoDao();
ArrayList<String> sa = catdao.showCategory();
for (String s : sa) {
%>

<option><%=s%></option>
<%
}
%>
</select>

My problem is how can i send the value of s to the DAO class???
(Since my jsp page already contains a form, it is not allowing me to create another from inside it..)
I have checked the posts regarding Cascading dropdown list in this site, but almost almost everywhere they are asking to use ajax.... but im not familier with it.. i want to achieve this functionality using java & jsp..
please help me out
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Diparnab Dey wrote:i want to achieve this functionality using java & jsp.

Then you are pretty much out of luck unless you resort to submitting the whole page and sending a response with the same page but with the changes (as if it were still 2001).

JavaScript and Ajax are the best way to do this, by far. If you're going to be working on web apps, these are skills you need to know. Avoiding them is only delaying the inevitable.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Diparnab Dey
Greenhorn

Joined: Aug 02, 2013
Posts: 3
Thanks...... Can you give me any idea how can i achive this using JavaScript?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

It becomes almost trivially easy using the jQuery JavaScript library.

You can find hundreds of example with a search, and this has been discussed many times in the HTML/JavaScript forum.

If you want to see some sample code, you can download the example code for my book jQuery in Action (2nd Ed). It's a free download. Look in the code for chapter8 and a folder named bootcloset.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Can Implement acascading dropdown list in jsp?