[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

If Logic

Hi,
My logic didnt worked, so I posed here to see if I can get the correct logic.
On my Edit.jsp page I'm getting a value from DB.  Below is the code.

<select size='1' name='type'>
<option selected>"+rs.getString(3)+"</option>");
<option>Beta</option>
<option>Release</option>
<option>updates</option>
<option>patchs</option>
</select>

Drop Down List has (Beta, Release, updates, patchs)
When Edit.jsp displays the select dropdown, I dont want the value coming from DB to be displayed again in <option>....
hope you understand.

Thanks.
0
princehyderabad
Asked:
princehyderabad
1 Solution
 
ManishLeadCommented:
>><option selected>"+rs.getString(3)+"</option>");
What is coming in rs.getString(3)..
So if that is Beta u want that Beta is selected value?
0
 
bloodredsunCommented:
<select size='1' name='type'>
<%
String selected = rs.getString(3) ;

if ( "Beta".equals( selected ) ){
      out.println("<option selected>Beta</option>");
}else{
      out.println("<option>Beta</option>");
}
if ( "Release".equals( selected ) ){
      out.println("<option selected>Release</option>");
}else{
      out.println("<option>Release</option>");
}
if ( "updates".equals( selected ) ){
      out.println("<option selected>updates</option>");
}else{
      out.println("<option>updates</option>");
}
if ( "patchs".equals( selected ) ){
      out.println("<option selected>patchs</option>");
}else{
      out.println("<option>patchs</option>");
}
%>
</select>

this means that if rs.getString(3) was "updates" it would output

<select size='1' name='type'>
<option>Beta</option>
<option>Release</option>
<option selected>updates</option>
<option>patchs</option>
</select>

which is what I assume you want.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now