0

Well . this is fairly a simple question. Lets say i have a registration form, some user has registered and i have the details in my database.

Now i can use the same form for letting the user edit his profile. I can prefill the textboxes by giving the following example

<input type="text" value="<%= some_userbean.getname() %>"  />

the problem is how to make an option of <select> marked as selected. i have it value in my database. Can this be done in JSP without using javascript. My selection menu in the form is static

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by karanits
0
<%
String init= "3";
%>

<select name="dropDown">
  <option value="1" <%= ( "1".equals(init) )?"selected":"" %> >One</option>
  <option value="2" <%= ( "2".equals(init) )?"selected":"" %> >Two</option>
  <option value="3" <%= ( "3".equals(init) )?"selected":"" %> >Three</option>
  <option value="4" <%= ( "4".equals(init) )?"selected":"" %> >Four</option>
  <option value="5" <%= ( "5".equals(init) )?"selected":"" %> >Five</option>
</select>

Although it is better to use a for loop for these things (<select>)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.