• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic selection of <option> in a JSP

 
Oogway Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

I have a JSP with html <select><option></option></select>. On initial load, a specific entry is selected with the <option> attribute of 'selected'. Based on a servlet result, can the selected <option> be changed - back and forth multiple times ? And if so, how ?



Cheers,
Oogway.
 
Paul Clapham
Sheriff
Posts: 21867
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you generate the HTML -- which is what you are doing with that JSP -- you can flag one of the options with the "selected" flag using the <c:if> element of JSTL.

However I'm not sure that was the question you were asking. There was something about "initial load", which sounds like what happens in a browser. That's irrelevant to JSP, as the JSP is just generating the HTML for the browser. And you asked whether the selected option could be changed, which also doesn't make sense -- who or what would be changing it?
 
Oogway Tan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

Explaining it a bit further, the .jsp is -


xyz.jsp.inc is


abc.jsp.inc is


pqr.jsp.inc is


This page gets called forward / backward as part of Struts Actions and also by way of a 'Refresh' button (Struts Action).

When the conditions are correct, the second <option> gets selected. But when the conditions are incorrect, the second <option> is still displayed, though I want the first <option> to be displayed.


Oogway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!