This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes retreving values from table and put it in Combo Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "retreving values from table and put it in Combo Box" Watch "retreving values from table and put it in Combo Box" New topic
Author

retreving values from table and put it in Combo Box

Sonu Philip
Greenhorn

Joined: Jun 15, 2006
Posts: 5
Hello Ranchers..
Here i'm doing a project in JSP and oracle. For that i want to display the client code in a combo box(select tag) and when ever i select that combo and change the value.. the clients address, phone number everything has to display in the text-fields given below.

Displaying the codes in the combo box is completed and it is working perfectly.. So what should i do to display the other values corresponding to the client_code in the below text-fields..

the code i've done is like this

-------------------------------------------------------------------------
<td><select size="1" name="shipper_code">
<option value="none" selected>--Select One--</option>
<%Statement stmt = dbCon.createStatement();
String query = "Select buyerclientcode from seaimp.buyerclient order by buyerclientcode";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{String code = rs.getString(1);
%>
<option value="<%=code%>"><%= code%></option>
<%
}
stmt.close();
//rs.close();
%>
</select></td>
---------------------------------------------------------------------------

It is displaying all the records in the table.. but i want to display the
address of the particular client when the user changes the client code

For that what should i do...
Please help me ranchers...
Thanks in advance

regards
Aravind
Srilakshmi Vara
Ranch Hand

Joined: Jul 21, 2004
Posts: 169
Same way as you did for the select box, After seleting a value from the execute the SQL Statement passing the selected value and get the address and populate the required values with the ResultSet
Aravind Prasad
Ranch Hand

Joined: Dec 28, 2005
Posts: 263
Thank you Srilakshmi,
Can u please give me some idea how to do that..
if using javascript it should come like this

<td><select size="1" name="shipper_code" onChange="validate(name,address,phone,mob);return false">
<option value="none" selected>--Select One--</option>
<% Statement stmt = dbCon.createStatement();
String query = "Select * from seaimp.buyerclient order by buyerclientcode";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{ String code = rs.getString(1);
String name = rs.getString(2);
String address = rs.getString(3);
String phone = rs.getString(4);
String mob = rs.getString(5);
%>
<option value="<%=code%>"><%= code%></option>
<%
}
stmt.close();
//rs.close();
%>
</select></td>

in java script it will be like this
<script language= "javascript">
function validate(String name,String address,String ph, String mob)
{
document.form1.name.value = name;
document.form1.add.value = address;
document.form1.ph.value = ph;
document.form1.mob.value = mob;
}
</script>

---------------------------------------------------------------------------
if we are doing like this.. means.. then how to pass the parameters to the function validate like this.. For that we have to put the values name,address,phone,mobile in the select value..

Help me too to do this..
I too have the same doubt..

Thanks in advance ranchers..
regards
Aravind
 
wood burning stoves
 
subject: retreving values from table and put it in Combo Box
 
Similar Threads
Combo box problem in jsp
urgent !!!!how to access contents of list in jsp
to retreive datas from mysql table in jsp
How to display the full value in select tag
in dropdown problem