• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get the index and value from option dropdown listbox in jsp page

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to find out how to handle the following:

I retrieve the data from the database by calling javabean and return the data back to the same jsp page and then display those values using html/javascript in the dropdown listbox.

how to get the value selected by user (to be used in java - as a condition - for retrieving data from database) without submitting the form? I have many fields in that form and each each field required to check whether the data exist in the database and then retrieve other data fo be displayed in another field in the form.

Part of the code for ref - trans_main.jsp
--------------------------------------
<%@page import="java.util.List.*;"%>
<jsp:useBean id = "trx" class="trx.TransDetails" />
<%
String jCompany;
ArrayList listCompany = new ArrayList();
int sizeCompany=0;
%>

<html>
<head><title>JSP Page</title></head>
<title>Form</title>

<body>

<form name="transaction" method="post" >
<input type="hidden" name="hid_page" value="main"/>

<table>
<th width="9%"align="left">Company</th>
<td width="1%" align="center">:</td><td width="5%" >

<select name="co_no" id="co_no" >
<option value="select"></option>
<%
listCompany = trx.display_company();;
ListIterator iter = listCompany.listIterator();
while (iter.hasNext()) {
jCompany =(String)iter.next();
%>
<option value="<%=jCompany %>"><%=jCompany %></option>
<% } %>
</select>
</td>
</tr>

<tr>
<th width="9%"align="left">Project</th>
<td width="1%" align="center">:</td><td width="25%">
<select name="proj_cde" >
<option value="select"></option>
-----

</select>
</td>
</tr>
</table>
</form>
</body>
</html>

TQ
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"tll cll",

You have already been asked twice to adjust your display name to JavaRanch standards. This is your 3rd and final warning. Accounts with invalid display names are removed.

Visit JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

bear
Forum Bartender
[ October 06, 2005: Message edited by: Bear Bibeault ]
 
Hot dog! An advertiser loves us THIS much:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic