tags:

views:

15

answers:

0

i am struck with a problem in jsp. in my form i have 2 drop down boxes. depending on the value selected in the first box (which is populated from DB), i have to populate the second box from the database. is it possible using jsp and javascript?

i did try to retrieve the value selected in the first menu using javascript n pass it in d query of jsp code, but it didn't work here is dat function


function createmenus()

{

 var form = document.getElementById('f1');

 var supplier_select = document.createElement('select');

 supplier_select.setAttribute('id','supplier');

 var index=document.getElementById("item").selectedIndex;

 var itemnumber=document.getElementById("item").option[index].value;

 <%

  String number="<script>document.writeln(itemnumber)</script>";

  Connection con=JdbcDAO.conn(); 

  PreparedStatement psmt;

  psmt = con.prepareStatement("select sup_no,sname from supplier where sup_no IN (select sup_no from supplier_item where itemno='number')");

  ResultSet rs=psmt.executeQuery();%>

 var temp="<%=rs%>";

 while(temp)

 {

    temp="<%=rs.next()%>";

    supplier_select.add(new Option("<%=rs.getString("sname")%>","<%=rs.getString("sup_no")%>"));

 }

 form.appendChild(supplier_select);

}

JdbcDAO is my self made class for DB connectivity


is possible at all this way?? plz help me out...... alternatives in java will do :)