| | |
Pre selecting combo box in JSP
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2008
Posts: 3
Reputation:
Solved Threads: 0
I have a collections to be populated in a JSP combo box. Now suppose there is a different page for each user which displays user specific values in a combo box in that page.
The combobox should display the value from the collection specific to the user. But my combo box just shows the first value which is <html:option> value.
Anyone knows how to do that? I mean pre selecting (a selected value of combo box) a user specific value in combo box.
to make it more simpler, lets say there is a combo box called "Manager" in the user page and it should display different Manager for different users. And this combo box is having a collection of managers.
The combobox should display the value from the collection specific to the user. But my combo box just shows the first value which is <html:option> value.
Anyone knows how to do that? I mean pre selecting (a selected value of combo box) a user specific value in combo box.
to make it more simpler, lets say there is a combo box called "Manager" in the user page and it should display different Manager for different users. And this combo box is having a collection of managers.
Last edited by comsec; Sep 19th, 2008 at 5:16 pm.
This is more of an HTML question rather than a JSP question,
You have to add the parameter
An example is as follows:-
Consider you combobox has four elements Volvo, Saab, Fiat and Audi and you want Fiat selected by default, then you would have to do the following:-
You have to add the parameter
selected="selected" for the Option element you want to be selected by default.An example is as follows:-
Consider you combobox has four elements Volvo, Saab, Fiat and Audi and you want Fiat selected by default, then you would have to do the following:-
html Syntax (Toggle Plain Text)
<html> <body> <form action=""> <select name="cars"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="fiat" selected="selected">Fiat</option> <option value="audi">Audi</option> </select> </form> </body> </html>
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
<html:option> is used with Apache Struts something like this example (There is no explanation to code, just reference from which book the code come )
For stuts tutorial on form you may consider look at this tutorial, maybe this from from IBM (based on Websphere, but general logic can be re-used) or Advanced Forms Handling in Struts 1.1 (includes example of code in zip form)
For stuts tutorial on form you may consider look at this tutorial, maybe this from from IBM (based on Websphere, but general logic can be re-used) or Advanced Forms Handling in Struts 1.1 (includes example of code in zip form)
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
I have no idea about the structure of your database what sort of data you keep but surly somewhere along you looking up/checking to what group user belong so you would be able to get this info and incorporate it in your selection...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Other Threads in the JSP Forum
- Previous Thread: Connection Pooling in Java
- Next Thread: Re: Java program need help!
| Thread Tools | Search this Thread |
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 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






