•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 363,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,885 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 38884 | Replies: 10
![]() |
•
•
Join Date: Dec 2004
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
HI,
I wish to get the values from the drop down menu selected by a user from the HTML page and pass this value into my servlet program for processing.
In my servlet program, I've used the getParameter() function to obtain the value from the drop down menu selected.
<SELECT name=Day>
<OPTION value="" selected>- Select -</OPTION>
<OPTION value=Sunday>Sunday</OPTION>
<OPTION value=Monday>Monday</OPTION>
<OPTION value=Tuesday>Tuesday</OPTION>
<OPTION value=Wednesday>Wednesday</OPTION>
<OPTION value=Thursday>Thursday</OPTION>
<OPTION value=Friday>Friday</OPTION>
<OPTION value=Saturday>Saturday</OPTION>
</SELECT>
String days= request.getParameter("Day");
System.out.println("DAY =" +days);
However, the value of the parameter "day" seems empty. May I know what is the correct method of getting the value selected from the drop down menu into my servlet? It did work when I use Javascript functions to extract it though (function getDay() in frmLockOut.html).
Attached are my JSP(frmLockOut.html) and Servlet(AdmProfileLockOut.java- see function add( ) ) source code files for reference.
Thanks
Danny
I wish to get the values from the drop down menu selected by a user from the HTML page and pass this value into my servlet program for processing.
In my servlet program, I've used the getParameter() function to obtain the value from the drop down menu selected.
<SELECT name=Day>
<OPTION value="" selected>- Select -</OPTION>
<OPTION value=Sunday>Sunday</OPTION>
<OPTION value=Monday>Monday</OPTION>
<OPTION value=Tuesday>Tuesday</OPTION>
<OPTION value=Wednesday>Wednesday</OPTION>
<OPTION value=Thursday>Thursday</OPTION>
<OPTION value=Friday>Friday</OPTION>
<OPTION value=Saturday>Saturday</OPTION>
</SELECT>
String days= request.getParameter("Day");
System.out.println("DAY =" +days);
However, the value of the parameter "day" seems empty. May I know what is the correct method of getting the value selected from the drop down menu into my servlet? It did work when I use Javascript functions to extract it though (function getDay() in frmLockOut.html).
Attached are my JSP(frmLockOut.html) and Servlet(AdmProfileLockOut.java- see function add( ) ) source code files for reference.
Thanks
Danny
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,583
Reputation:
Rep Power: 18
Solved Threads: 186
•
•
Join Date: Apr 2005
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi , all
Can anyone please tell me how to get multiple values from a drop down menu . I know that we have to specify MULTIPLE in SELECT tag
This is my simple code, I wnat to display selected values in dd.jsp , if anyone can help me ,, PLEASE DO IT SOOON..
<FORM Action="dd.jsp">
<SELECT NAME="drop" SIZE=3 multiple>
<OPTION> Authoring
<OPTION> Internet
<OPTION> Location
<OPTION> Multimedia
<OPTION> Reference
<OPTION> Software
</SELECT>
<input type ="submit">
</FORM>
Can anyone please tell me how to get multiple values from a drop down menu . I know that we have to specify MULTIPLE in SELECT tag
This is my simple code, I wnat to display selected values in dd.jsp , if anyone can help me ,, PLEASE DO IT SOOON..
<FORM Action="dd.jsp">
<SELECT NAME="drop" SIZE=3 multiple>
<OPTION> Authoring
<OPTION> Internet
<OPTION> Location
<OPTION> Multimedia
<OPTION> Reference
<OPTION> Software
</SELECT>
<input type ="submit">
</FORM>
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,583
Reputation:
Rep Power: 18
Solved Threads: 186
PLEASE DO IT SOOON
Wrong way to ask a question. We're not here to do your bidding at your whim. Maybe you should have started researching sooner if you're in a hurry now.
the multiselect is not possible with a dropdown, only with a selectbox.
You can get the values with getParameterValues(String) on the ServletRequest.
The API docs will give you more information.
Wrong way to ask a question. We're not here to do your bidding at your whim. Maybe you should have started researching sooner if you're in a hurry now.
the multiselect is not possible with a dropdown, only with a selectbox.
You can get the values with getParameterValues(String) on the ServletRequest.
The API docs will give you more information.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
•
•
Join Date: Aug 2005
Location: Socialist Republic of Boulder
Posts: 216
Reputation:
Rep Power: 3
Solved Threads: 5
You should be creating a new topic for a new question. You also might want to be asking this question in the JavaScript forum.
Regards,
Nate
Regards,
Nate
•
•
Join Date: Jan 2006
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
Try this, it works for me
Try this, it works for me
<% String days= request.getParameterValues("Day"); %> •
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,583
Reputation:
Rep Power: 18
Solved Threads: 186
•
•
Join Date: Feb 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
lets say I have a select box like
ok now if I want to get all the selected values of this multiple select box I just call :-
but now my problem is how do I get the text values.
I know in JavaScript I can get both the text and the values by just issuing :-
but how do I do this in Servlet, how do I do this in J2EE programmming ? :!:
How do I get the selected text value ?
<SELECT id="MySelect" multiple > <option value="A">Text 1<option> <option value="B">Text 2<option> <option value="C">Text 3<option> </SELECT>
ok now if I want to get all the selected values of this multiple select box I just call :-
String[] arrValues[] = objRequest.getParameterValues("MySelect");but now my problem is how do I get the text values.
I know in JavaScript I can get both the text and the values by just issuing :-
document.getElementById("MySelect").value;
document.getElementById("MySelect").text;but how do I do this in Servlet, how do I do this in J2EE programmming ? :!:
How do I get the selected text value ?
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
- XP Startup Problem: Infinite Loop (Windows NT / 2000 / XP / 2003)
- for validation - text box and drop down menu (JavaScript / DHTML / AJAX)
- opera problems with hover menu (JavaScript / DHTML / AJAX)
- Cd Tary Wont Open (Storage)
- php + Javascript (PHP)
- daniweb on my start menu (Windows NT / 2000 / XP / 2003)
- PHP/SQL query help (PHP)
- For some reason program installations cannot create new start menu shortcuts... (Windows NT / 2000 / XP / 2003)
- IE6 has been constantly hijacked by .... (Viruses, Spyware and other Nasties)
Other Threads in the JSP Forum
- Previous Thread: day in a calender
- Next Thread: facing problem in database connectivity in jsp to mysql



Linear Mode