Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    Falls Chuch, VA
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post

    if statment problem

    Hi the if statement in my code is not getting executed. It is moving to the else statement.

    Please help me

    Code:
    Vector vRocks = cr.getRocks();
        for (int j=0; j<10; j++)
        {
          String sShowHide = j<(vRocks.size()+1)?"block":"none";
          String sRockName = "";
          int rockId = -1;
    
          if ( j<vRocks.size() )
          {
            BigRock br = (BigRock)vRocks.get(j);
            sRockName = br.getName();
            rockId    = br.getID();
          }
    
    &#37;>
    <td class=formPromptSmall > <% if ( j==0 ) { %> Big Rocks: &nbsp; <% } %> </td>
    <%
        
        if (sRockName == "physical" || sRockName == "social" || sRockName == "mental" || sRockName == "spiritual")
          {
    %>
       <td class=formInput17> <div id="rock2_<%=i%>_<%=j%>" style="display: <%=sShowHide%>;">
         <input type=text name="rockname_<%=i%>_<%=j%>" class=textInput size=40 value="<%=sRockName%>" onFocus="javascript:ToggleSet('rock2_<%=i%>_<%=j+1%>','block');" disabled>
         <input type=hidden name="rockid_<%=i%>_<%=j%>" class=textInput value="<%=rockId%>">
        </div>
       </td>
      <%
          }
       else
         {
     %>
      <td class=formInput17> <div id="rock2_<%=i%>_<%=j%>" style="display: <%=sShowHide%>;"> 
        <input type=text name="rockname_<%=i%>_<%=j%>" class=textInput size=40 value="<%=sRockName%>" onFocus="javascript:ToggleSet('rock2_<%=i%>_<%=j+1%>','block');">
        <input type=hidden name="rockid_<%=i%>_<%=j%>" class=textInput value="<%=rockId%>">
       </div>
      </td>
    </tr>
    <%
            }
        }
    The values i asssigned physical, mental , spiritual, social are the values of the sRockName which i found while debugging. Please let me know if anybody know the solution.


    Thanks in Advance
    Last edited by Aradon; 09-12-2008 at 12:31 PM.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by adi501 View Post
    Code:
    <%
        
        if (sRockName == "physical" || sRockName == "social" || sRockName == "mental" || sRockName == "spiritual")
          {
    %>
    In java you use the equals method for string comparison like so

    Code:
    if ( "physical".equals(sRockName) || ...) {
    }
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •