Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 19th, 2001, 10:58 AM
43rdworld 43rdworld is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 29 43rdworld User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 36 sec
Reputation Power: 0
Can't compare strings

I'm trying to compare strings in a select statement. It's part of an edit function that selects a records and loads the results in a form. The select box that lists the locations does not work. I'm feeding all the right information as I've echoed out the values but I can't get a match. The location in the list box always 'checks' the last one take from the db. My code is:

<select name="jobLocation" class="dropdown">
<option value="" checked>Select a Location
<%
String locQuery = "SELECT locID, jobLocation from tblHRLocations";
// get result
ResultSet SQLLocationResult = SQLStatement.executeQuery(locQuery);
while(SQLLocationResult.next())
{
jobLocation = SQLLocationResult.getString("jobLocation");
jobLocation = jobLocation.trim();
%>
<option value="<%out.println(jobLocation);%>" <%if(jobLocationSelected.equals(jobLocation));{%>selected<%}%>><%out.println(jobLocation);%>
<%
}
%>
</select>

Can anyone tell me what I'm doing wrong? This is a real showstopper right now and I really need some help.

Thanks.

Bob

Reply With Quote
  #2  
Old September 19th, 2001, 05:09 PM
Alexandr Alexandr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Belarus
Posts: 30 Alexandr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
hi 43rdworld
this world is 43rd for you?

you made some little mistake here
Code:
<option value="<%out.println(jobLocation);%>" <%if(jobLocationSelected.equals(jobLocation)); {%>selected<%}%><%out.println(jobLocation);%> 


better way to write this
Code:

<option value="<%=jobLocation%>" <%=jobLocationSelected.equals(jobLocation) ? "SELECTED" : "" %> 
><%=jobLocation%> 

Reply With Quote
  #3  
Old September 19th, 2001, 06:50 PM
43rdworld 43rdworld is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 29 43rdworld User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 36 sec
Reputation Power: 0
Well, so far the world is the only one but I think this is my 43rd ID on these forums as I keep forgetting the previous one. Actually, it's for 1/43 scale models and the web site I'm developing.

Thanks for the answer. I've never seen that particular format in any of the books I've read but am extremely glad for the answer! Much appreciated!

Bob

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Can't compare strings

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap