Geeks Talk

Prepare for your Next Interview




combo in jsp

This is a discussion on combo in jsp within the JSP forums, part of the Web Development category; hi frineds i want to use a jsp page, which connects to DB and retrieves info from it(say lastname).the retrieved info should be inserted into COMBOBOX Please tell ...


Go Back   Geeks Talk > Web Development > JSP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-17-2007
Expert Member
 
Join Date: Oct 2005
Location: india,cochi,bangalore
Posts: 395
Thanks: 2
Thanked 8 Times in 7 Posts
vmshenoy is on a distinguished road
combo in jsp

hi frineds

i want to use a jsp page, which connects to DB and retrieves info from it(say lastname).the retrieved info should be inserted into COMBOBOX
Please tell how can one do it!
__________________
:)
NEVER SAY DIE.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-17-2007
Contributing Member
 
Join Date: Sep 2006
Location: bangalore, india
Posts: 1,007
Thanks: 0
Thanked 76 Times in 64 Posts
psuresh1982 will become famous soon enough
Re: combo in jsp

I think in jsp page you can also use html code. Checkout the following code.

<select name="test">
<option><% = lastname(this what you getting from database) %></option>
</select>

------------------
suresh
Reply With Quote
  #3 (permalink)  
Old 03-17-2007
Expert Member
 
Join Date: Oct 2005
Location: india,cochi,bangalore
Posts: 395
Thanks: 2
Thanked 8 Times in 7 Posts
vmshenoy is on a distinguished road
Re: combo in jsp

hi suresh
but it will return more than one row from DB!
suppose it returns three rows!

i am storing these three names in array like
arr[]=rs.getString("lastname");
now i want to add it to combo box
<select name="..">
<option><??? ????</option?

how to solve this!

this is the scenario iam speaking about!

hoping answer soon!
__________________
:)
NEVER SAY DIE.
Reply With Quote
  #4 (permalink)  
Old 03-19-2007
Junior Member
 
Join Date: Mar 2007
Location: Bangalore
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
pramod.reddy is on a distinguished road
Re: combo in jsp

Hi ,
I dont know whether u r using any framework or following any architecture. If u r not using any framework or CustomTags , u can adapt the procedure given below.

If u have a collection or an array of objects iterate them using a loop and add these values to a combobox.
You can write a Scriplet to do this.

for wg:- if you have an array names of size 10 i.e., names[10] then u can iterate u r array in this way

<%
for(int i=0,n=names.length[];i<n;i++){
%>
<select name="test">
<option><% = names[i] %></option>
</select>
<%
}
%>

Last edited by pramod.reddy : 03-19-2007 at 06:04 AM.
Reply With Quote
The Following User Says Thank You to pramod.reddy For This Useful Post:
  #5 (permalink)  
Old 03-19-2007
Expert Member
 
Join Date: Oct 2005
Location: india,cochi,bangalore
Posts: 395
Thanks: 2
Thanked 8 Times in 7 Posts
vmshenoy is on a distinguished road
Re: combo in jsp

thanks pramod!Though i got the solution that day itself, i forgot to write here!
But still too much thanks! Hope you will help me in other problems too(as i come across)!
__________________
:)
NEVER SAY DIE.
Reply With Quote
Reply

  Geeks Talk > Web Development > JSP


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Select a different value from the combo box JobHelper WinRunner 1 12-26-2006 11:17 AM


All times are GMT -4. The time now is 01:38 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved