943,994 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 6454
  • JSP RSS
Mar 18th, 2007
-1

Combo box and Ms-access

Expand Post »
how can I extract all the values of one field from the database table (ex : all the names from the field NAME) and put them in a combo box in run time in the dynamically generated page…

and secondly, if all the values are available in the combo box, how can I select one value at a time from the combo box and store that value in a variable during run time…
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rittik is offline Offline
1 posts
since Mar 2007
Apr 2nd, 2007
0

Re: Combo box and Ms-access

Click to Expand / Collapse  Quote originally posted by rittik ...
how can I extract all the values of one field from the database table (ex : all the names from the field NAME) and put them in a combo box in run time in the dynamically generated page…

and secondly, if all the values are available in the combo box, how can I select one value at a time from the combo box and store that value in a variable during run time…

hai..

I just give you the code for displaying and storing the values in the run time(part of code).


<%
//query for selecting the values from the database
pstmt1=con.createStatement();
rs=pstmt1.executeQuery("select * from test.emp");
%>

<!-- Displaying the values in the combo box -->
<form name="form1" method="post" action="">
<center>
<p>Select the Employee Id from the Combo box
<select name="eid" id="eid" onchange="filename.jsp">
<%
while(rs.next())
{
%>
<OPTION VALUE="<%=rs.getString("empid")%>"><%=rs.getString("empid")%></OPTION>
<%
}
%>
</select>
</p>
<p>
<input name="Submit" type="submit" id="submit" value="Submit">
</p>
</center>
</form>

<!-- Storing the value in the id variable during run time-->
<%
id=request.getParameter("eid");
%>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Thendral is offline Offline
14 posts
since Feb 2007
Apr 2nd, 2007
0

Re: Combo box and Ms-access

NEVER try to connect to database from JSP!
If you need data from DB use servlet and then pass them to your JSP...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,658 posts
since Dec 2004
Apr 2nd, 2007
0

Re: Combo box and Ms-access

Click to Expand / Collapse  Quote originally posted by peter_budo ...
NEVER try to connect to database from JSP!
If you need data from DB use servlet and then pass them to your JSP...
Hai..

I am also beginner for Jsp.
Can you please tell me the reason(for not connecting the DB from JSP) so that i can understand the concept well.

Thanking you.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Thendral is offline Offline
14 posts
since Feb 2007
Apr 2nd, 2007
0

Re: Combo box and Ms-access

JSP is a display technology, it is NOT meant to contain business logic.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: new to javascript
Next Thread in JSP Forum Timeline: how to get servers date





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC