Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-11-2008, 10:26 PM   PM User | #1
adi501
New Coder

 
Join Date: Jul 2008
Location: Falls Chuch, VA
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
adi501 is an unknown quantity at this point
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();
      }

%>
<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 11:31 AM..
adi501 is offline   Reply With Quote
Old 09-12-2008, 11:32 AM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
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
shyam is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:31 PM.


Advertisement
Log in to turn off these ads.