If Logic

Posted on 2005-04-26
Last Modified: 2010-04-01
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>");

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.

Question by:princehyderabad
    LVL 11

    Expert Comment

    >><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?
    LVL 29

    Accepted Solution

    <select size='1' name='type'>
    String selected = rs.getString(3) ;

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

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

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

    which is what I assume you want.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now