Drop down menu problem

Hi,

I am using two drop down menu's. Now when even I select any thing in my 1 drop down, automatically the values in the second drop down should come up depending upon the selection of 1st drop down.

Its like I have several categories and selecting upon any category in 1st drop down, all the sub categories related to that category should be made avail in 2 drop down.

I want to fetch the data from the database in both cases.

i.e if any category is selected, the sub category will be fetched from the database and displayed in second drop down.

Hope I made clear wht I am saying.

Please help with this.

Aniketh

[662 byte] By [aniketh_parmara] at [2007-11-27 9:28:08]
# 1
Hi,Please can any one give me the solution for the above prob?
aniketh_parmara at 2007-7-12 22:32:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
I don't see any specific coding question. I only see some simple requirements.Just interpret the requirements and write code accordingly. Ask specific questions if you stucks while writing. For example if you don't know how to add a value to an ArrayList<String>.
BalusCa at 2007-7-12 22:32:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
U can refer this link below http://forum.java.sun.com/thread.jspa?threadID=597553
a1ba at 2007-7-12 22:32:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Hi,

I have found the solution about the two drop down list. Now it is working fine. But the problem is the text field input data is vanishing now. since I am refreshing the page after taking the value of the 1 st drop down .

Like I am taking name,author.... category(1st drop down) and sub category(2nd drop down) from the user.

User fills the name, author .... and category(onchange) :

As soon as user select category, the same page is called again and now the category is passed as a parameter and values for subcategories are populated.

But the problem is about those name, author... this data is vanished as the page is refreshed

Please any one help me with this I am stuck @ this point.

Following is the code:

<jsp:useBean id="MDBAO" class="material.MaterialDBAO" />

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="material.*" import="java.sql.*" errorPage="" import="java.util.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Update</title>

<link rel="stylesheet" href="StyleSheet.css" />

<SCRIPT language=JavaScript>

function reload(form){

var val=form.category.options[form.category.selectedIndex].value;

self.location='Update.jsp?update=AddMaterial&category=' + val ;

}

</script>

<%

String update = request.getParameter("update");

if(update.equals("AddMaterial"))

{

%>

<table width="544" class="sidebarHeader">

<form name="category2" action="TempUpdate.jsp" method="get">

<tr>

<td>Name</td>

<td><input name="name" type="text" /></td>

</tr>

<tr>

<td>Author</td>

<td><input name="author" type="text" /></td>

</tr>

<tr>

<td>Description</td>

<td> <textarea name="description" cols="50" rows="3"></textarea></td>

</tr>

<tr>

<td>Location</td>

<td><input name="location" type="text" /></td>

</tr>

<tr>

<td>Submitted By</td>

<td><input name="submitter" type="text" /></td>

</tr><tr>

<td>File Format</td>

<td><input name="fileformat" type="text" /></td>

</tr><tr>

<td>File Size</td>

<td><input name="filesize" type="text" /></td>

</tr>

<tr>

<td>Date Submitted</td>

<td> <select name="month">

<option>JAN</option>

<option>FEB</option>

<option>MAR</option> ............

</select>

<select name="day">

<option>1</option>

<option>2</option> .........

</select>

<select name="year">

<option>1998</option>

<option>1999</option>

<option>2000</option>

<option>2001</option>

<option>2002</option>

<option>2003</option>

<option>2004</option>

<option>2005</option>

<option>2006</option>

<option>2007</option>

<option>2008</option>

<option>2009</option>

<option>2010</option></select></td>

</tr>

<tr>

<td>Category</td>

<td><select name="category"> <option>Select Category</option> <option value="12">Palak</option>

<%

try

{

ArrayList<Category> cat = MDBAO.getCategories_display();

Iterator iterate = cat.iterator();

while(iterate.hasNext())

{

Category c=(Category)iterate.next();

%>

<option value="<%=c.getCatid()%>"><%=c.getCategory()%></option>

<%

}

%>

</select>

<%

}

catch(Exception e)

{

System.out.print("Error while getting categories on JSP "+e.getMessage());

}

%> </td></tr>

<%

String cat = request.getParameter("category");

int c = 0;

if(cat!=null)

{

c = Integer.parseInt(cat);

%>

<td>Sub Category</td>

<td><select name="scategory"> <option>Select SubCategory</option>

<%

try

{

ArrayList<Scategory> **** = MDBAO.getSubcategories_display(c);

Iterator iterat = ****.iterator();

while(iterat.hasNext())

{

Scategory s=(Scategory)iterat.next();

%>

<option><%=s.getScategory()%></option>

<%

}

%>

</select>

<%

}

catch(Exception e)

{

System.out.print("Error while getting categories on JSP "+e.getMessage());

}

}

%>

</td></tr>

<tr>

<td></td>

<td>

<input name="Reset" type="reset" value="Reset" />

<input name="Submit" type="submit" value="AddMaterial" onClick ="return Check2();" /></td>

</tr>

</form></table>

<%

}

}

%>

</body>

</html>

aniketh_parmara at 2007-7-12 22:32:00 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...