ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Closed Thread
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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 25th, 2004, 08:28 PM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Displaying commas and hyphens

This is going to be very basic...

I want to display records with varying results, in this case 'Practice1', 'Practice2', …’Practice6’. However, not all members have 6 practices.

I want each ‘Practice’ record separated by a comma, without out displaying unnecessary commas. The following is definitely not the way to go. Any suggestions?

Thanks in advance.

<ul>
<cfoutput query="GetMembers">
<tr>
<td height="20" colspan="5" align="left" class="style2">
<li><A HREF="LawDetailsForm.cfm?UserID=#URLEncodedFormat(Trim(UserID))#">#FName# #MI# #LName#</a> - #Status#</li></td>
</tr>
<tr>
<td height="20" colspan="5" align="left" class="style4">#Practice1#, #Practice2#, #Practice3#, #Practice4#, #Practice5#, #Practice6#</td>
</tr>
</cfoutput>
</ul>

Reply With Quote
  #2  
Old August 26th, 2004, 06:21 AM
stpaz stpaz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 17 stpaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 51 sec
Reputation Power: 0
Hi Steve try this

Try this

<ul> <cfoutput query="GetMembers">

<cfset PracticeList = ''>

<cfloop from="1" to="6" index="i">

<cfif len(trim(GetMembers['Practice'&i]))>

<cfset PracticeList = listappend(PracticeList,GetMembers['Practice'&i])>

</cfif>

</cfloop>

<tr> <td height="20" colspan="5" align="left" class="style2"> <li><A HREF="LawDetailsForm.cfm?UserID=#URLEncodedFormat(Trim(UserID))#">#FName# #MI# #LName#</a> - #Status#</li></td> </tr>

<tr><td height="20" colspan="5" align="left" class="style4">#PracticeList#&nbsp;</td></tr>

</cfoutput> </ul>

Reply With Quote
  #3  
Old August 26th, 2004, 07:48 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,310 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 4 h 20 m 43 sec
Reputation Power: 888
i prefer this, it's a lot simpler --

<td height="20" colspan="5" align="left" class="style4">
<cfif len(Practice1)>#Practice1#, </cfif>
<cfif len(Practice2)>#Practice2#, </cfif>
<cfif len(Practice3)>#Practice3#, </cfif>
<cfif len(Practice4)>#Practice4#, </cfif>
<cfif len(Practice5)>#Practice5#, </cfif>
<cfif len(Practice6)>#Practice6#</cfif></td></tr>
__________________
r937.com | rudy.ca

Reply With Quote
  #4  
Old August 26th, 2004, 08:09 AM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by r937
i prefer this, it's a lot simpler --

<td height="20" colspan="5" align="left" class="style4">
<cfif len(Practice1)>#Practice1#, </cfif>
<cfif len(Practice2)>#Practice2#, </cfif>
<cfif len(Practice3)>#Practice3#, </cfif>
<cfif len(Practice4)>#Practice4#, </cfif>
<cfif len(Practice5)>#Practice5#, </cfif>
<cfif len(Practice6)>#Practice6#</cfif></td></tr>


I like this solution but I would move the commas around so that the first element's comma is on the second line, etc. Because the first element being present is no guarantee that a second will be, so unless you get all 6 elements you will have a stray comma at the end.

wdn2k

Reply With Quote
  #5  
Old August 26th, 2004, 08:13 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,310 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 4 h 20 m 43 sec
Reputation Power: 888
good catch, wdn2k, i can't believe i did that!!

Reply With Quote
  #6  
Old August 26th, 2004, 09:10 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,310 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 4 h 20 m 43 sec
Reputation Power: 888
uh oh, hold on a sec

if the first element is missing, and any other is present, you'll get that leading comma

but if the app fills in the 6 slots from left to tight, it may not be a concern


Reply With Quote
  #7  
Old August 26th, 2004, 09:38 AM
stpaz stpaz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 17 stpaz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 51 sec
Reputation Power: 0
<cfset PracticeList = ''>
<cfloop from="1" to="6" index="i">
<cfif len(trim(GetMembers['Practice'&i]))>
<cfset PracticeList = listappend(PracticeList,GetMembers['Practice'&i])>
</cfif>
</cfloop>


Reply With Quote
  #8  
Old August 26th, 2004, 12:58 PM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for all of the help. I have received much better advise from this forum than anywhere else.

Currently I have opted for r937's idea. My only concern is that there is always a trailing comma, even after the last entry.

I tried stpaz's latest and received the following error:

Complex object types cannot be converted to simple values.
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a <CFIF> tag. This was possible in ColdFusion 2.0 but creates an error in later versions.


The error occurred in C:\Inetpub\wwwroot\Lawyer\FirmDetailsForm.cfm: line 161

159 : <cfset PracticeList = ''>
160 : <cfloop from="1" to="6" index="i">
161 : <cfif len(trim(GetMembers['Practice'&i]))>
162 : <cfset PracticeList = listappend(PracticeList,GetMembers['Practice'&i])>
163 : </cfif>

Thanks again for the help. I've been away for two years and am very rusty.

Reply With Quote
  #9  
Old August 26th, 2004, 02:13 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by r937
uh oh, hold on a sec

if the first element is missing, and any other is present, you'll get that leading comma

but if the app fills in the 6 slots from left to tight, it may not be a concern



If it were me I'd make sure the slots were filled in the order I needed.

Reply With Quote
  #10  
Old August 26th, 2004, 04:20 PM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by wdn2000
If it were me I'd make sure the slots were filled in the order I needed.


Done that. However, there is still the trailing comma after the last slot, regardless of which one:

Practice1, Practice2, Practice3, Practice4, Practice5, Practice6,

BTW, thanks to everyone for your help and patience...

Reply With Quote
  #11  
Old August 26th, 2004, 05:42 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by Global777
Done that. However, there is still the trailing comma after the last slot, regardless of which one:

Practice1, Practice2, Practice3, Practice4, Practice5, Practice6,

BTW, thanks to everyone for your help and patience...


My post above solves that. Place the comma that would follow element1 just before element2, etc.

<cfif len(Practice1)>#Practice1# </cfif>
<cfif len(Practice2)>, #Practice2# </cfif>
<cfif len(Practice3)>, #Practice3# </cfif>
etc.

wdn2k

Reply With Quote
  #12  
Old August 26th, 2004, 06:03 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,310 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 4 h 20 m 43 sec
Reputation Power: 888
Quote:
Originally Posted by wdn2000
My post above solves that.
, yeah, but not if Practice1 is empty

Reply With Quote
  #13  
Old August 26th, 2004, 06:14 PM
wdn2000's Avatar
wdn2000 wdn2000 is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Apr 2000
Posts: 1,058 wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level)wdn2000 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 Days 20 h 56 m 43 sec
Reputation Power: 16
Quote:
Originally Posted by r937
, yeah, but not if Practice1 is empty


If it were me I'd make sure the slots were filled in the order I needed....

Reply With Quote
  #14  
Old August 26th, 2004, 07:37 PM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by wdn2000
If it were me I'd make sure the slots were filled in the order I needed....

You guys are the best! Thanks. Now that I see what you did, I'm embarassed that I didn't think of it.

Thanks again...

Reply With Quote