• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Can Implement acascading dropdown list in jsp?

 
Diparnab Dey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Diparnab Dey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...... Can you give me any idea how can i achive this using JavaScript?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic