473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Populating dropdown dynamically

Hi,

I have an arraylist(al) in which I have some values. I want to populate these values in my dropdown list. I have used the following code


Expand|Select|Wrap|Line Numbers
  1. <select name="select">
  2. <%for(int i=0;i<al.size();i++){%>
  3. <Option value="<%al.get(i);%>"><%=al.get(i)%></Option>
  4. <%}%>
  5. </select>

I gets populaated but when i want to print its value it shows blank.
Can anybody tell me the reason and some other alternative to populate the dropdown so that i can get the selected value.

Thanks
Oct 26 '07 #1
7 17917
r035198x
13,262 8TB
Hi,

I have an arraylist(al) in which I have some values. I want to populate these values in my dropdown list. I have used the following code


Expand|Select|Wrap|Line Numbers
  1. <select name="select">
  2. <%for(int i=0;i<al.size();i++){%>
  3. <Option value="<%al.get(i);%>"><%=al.get(i)%></Option>
  4. <%}%>
  5. </select>

I gets populaated but when i want to print its value it shows blank.
Can anybody tell me the reason and some other alternative to populate the dropdown so that i can get the selected value.

Thanks
Your value is not set properly.
You should have it as
Expand|Select|Wrap|Line Numbers
  1. value="<%=al.get(i)%>"
Oct 26 '07 #2
Your value is not set properly.
You should have it as
Expand|Select|Wrap|Line Numbers
  1. value="<%=al.get(i)%>"
Hi,
Now i am able to display its value but when I want to get its value on a servlet that is called from this jsp it shows blank.

Please tell me the reason.

Thanks
Oct 26 '07 #3
r035198x
13,262 8TB
Hi,
Now i am able to display its value but when I want to get its value on a servlet that is called from this jsp it shows blank.

Please tell me the reason.

Thanks
How are you retrieving this value from the servlet?
Can you post the code that'd displaying the blank values?
Oct 26 '07 #4
How are you retrieving this value from the servlet?
Can you post the code that'd displaying the blank values?
Hi,

I am using

Expand|Select|Wrap|Line Numbers
  1. String str=request.getParameter("name value od dropdown");
  2. PrintWriter pw=response.getWriter();
  3. pw.println("<html><body>");
  4. pw.println(str);
  5. pw.println("</body></html>");
Is it ok to get the selected value of dropdown using request.getParameter()?

Thanks
Oct 26 '07 #5
r035198x
13,262 8TB
Hi,

I am using

Expand|Select|Wrap|Line Numbers
  1. String str=request.getParameter("name value od dropdown");
  2. PrintWriter pw=response.getWriter();
  3. pw.println("<html><body>");
  4. pw.println(str);
  5. pw.println("</body></html>");
Is it ok to get the selected value of dropdown using request.getParameter()?

Thanks
Yes it's OK (correct) to use request.getParameter for select values.
What is the name of the select that you are passing to the getParameter method? It has to match exactly (case sensitive) with the name that you used on your form for the select.
I also suggest that you change the name of your select from "select" to something else that describes the values stored by the select.
Oct 26 '07 #6
Yes it's OK (correct) to use request.getParameter for select values.
What is the name of the select that you are passing to the getParameter method? It has to match exactly (case sensitive) with the name that you used on your form for the select.
I also suggest that you change the name of your select from "select" to something else that describes the values stored by the select.
Hi,
Thanx for ur response.
I am using the dropdown name as location.

Actually first i change one dropdown and call a servlet in which i fetch the values for another dropdown and passes it to the same jsp using request dispatcher.
But when i submit this jsp to another servlet i am not getting the values of fields.
Please help.

Thanks
Oct 26 '07 #7
r035198x
13,262 8TB
Hi,
Thanx for ur response.
I am using the dropdown name as location.

Actually first i change one dropdown and call a servlet in which i fetch the values for another dropdown and passes it to the same jsp using request dispatcher.
But when i submit this jsp to another servlet i am not getting the values of fields.
Please help.

Thanks
When you pass the values from the servlet to the JSP are they displaying properly on that JSP?
Oct 26 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: dmedina | last post by:
#1) put the data in table AA and put a flag like "New Detail" yes,no and requery you database and if user has selected "New Detail" then add ther previous data plus the data with the flag.... ...
1
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt"...
1
by: PraveenAnekalmat | last post by:
Hi, While sending mails, if we type a character in the To field, it should list all the id's starting with that character.Now i'm making ajax call using onkeyPress. But only 1 value is...
0
by: jdrott1 | last post by:
'i'm trying to populate a dropdown list from a column in an odbc connection. this is what i have so far and i seem to be lost. i don't understand how to go from the data adapter to populating the...
1
by: seshu veluri | last post by:
hai, i am using combobox to select the some options.now i am using the values from jsp page by giving the <select> options.now i want use the list from the database.so i created the table for...
1
by: itgaurav198 | last post by:
Hi, I have an arraylist(al) in which I have some values. I want to populate these values in my dropdown list. I have used the following code <select name="select"> <%for(int...
4
parshupooja
by: parshupooja | last post by:
Hey All, I have a dropdown on my page. I want to populate dropdown dynamically via code. Here is a scenario. for each year it should populate items automatically. such as most current item it...
4
by: cherryst152 | last post by:
I keep getting problems with this. What i want to do is populate my dropdown list with the names of the columns in one of my database tables. Whatever i try to do i keep somehow filling it in with...
4
by: Cainnech | last post by:
Hi all, I have this code <html> <head> <script type="text/javascript"> var path = "C:\\Test\\Directory" function ShowFolderFileList()
0
by: Kalkin | last post by:
Hi i am having trouble with the following problem any help would be appreciated:: The gridview starts off with empty text boxes for input along with already populated dropdowns to choose from for...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.