| | |
getting values from drop down menu
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Dec 2004
Posts: 8
Reputation:
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: Apr 2005
Posts: 2
Reputation:
Solved Threads: 1
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>
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Aug 2005
Posts: 216
Reputation:
Solved Threads: 8
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:
Solved Threads: 1
Hi,
Try this, it works for me
Try this, it works for me
JSP Syntax (Toggle Plain Text)
<% String days= request.getParameterValues("Day"); %>
•
•
Join Date: Feb 2006
Posts: 1
Reputation:
Solved Threads: 1
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 ?
JSP Syntax (Toggle Plain Text)
<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 :-
JSP Syntax (Toggle Plain Text)
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 :-
JSP Syntax (Toggle Plain Text)
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 ?
![]() |
Similar Threads
- using drop down menu with to insert data through php (PHP)
- drop down menu call javascript function (JavaScript / DHTML / AJAX)
- opopulate textfields based on drop down menu selection (ColdFusion)
- for validation - text box and drop down menu (JavaScript / DHTML / AJAX)
- Is it possible to pass hidden value in <select> drop down menu? (PHP)
- Drop Down Menu Help! (Web Browsers)
Other Threads in the JSP Forum
- Previous Thread: Online examination system
- Next Thread: search text from my webpages
Views: 69243 | Replies: 12
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






