473,372 Members | 1,091 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,372 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 17912
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.