Solved

No last comma

Posted on 2003-11-20
6
293 Views
Last Modified: 2013-12-24
With the code below I need it changed to not output a comma when it is done with all SubCatagories of a TopCatagory:

 <CFOUTPUT query="q_LinkCatagories">
  <CFIF IsDefined("LastTopCatagory")>
   <CFIF TopCatagory neq LastTopCatagory>); listB.addOptions("#TopCatagory#",</CFIF>
   "#SubCatagory#", "#SubCatagory#",
   <CFSET LastTopCatagory = TopCatagory>
  <CFELSE>
   listB.addOptions("#TopCatagory#",
   "#SubCatagory#", "#SubCatagory#",
   <CFSET LastTopCatagory = TopCatagory>
  </CFIF>
 </CFOUTPUT>);

This is what it outputs now:

listB.addOptions("Programming", "Perl", "Perl", "CSS", "CSS", "PHP", "PHP", "JavaScript", "JavaScript", "Coldfusion", "Coldfusion", ); listB.addOption ("Motorsports", "300ZX", "300ZX", "JDM", "JDM", "3000GT", "3000GT", "Eclipse", "Eclipse", "RX7", "RX7", "Import Show", ); listB.addOptions("Fitness", "Running", "Running", "Weight Training", "Weight Training", );

Notice the comma before the closing parentheses?
0
Comment
Question by:Max_Davis
  • 4
  • 2
6 Comments
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9792017
Try removing the last comma before the line :

    <CFSET LastTopCatagory = TopCatagory>

So the final code would be this one :

 <CFOUTPUT query="q_LinkCatagories">
  <CFIF IsDefined("LastTopCatagory")>
   <CFIF TopCatagory neq LastTopCatagory>); listB.addOptions("#TopCatagory#",</CFIF>
   "#SubCatagory#", "#SubCatagory#"
   <CFSET LastTopCatagory = TopCatagory>
  <CFELSE>
   listB.addOptions("#TopCatagory#",
   "#SubCatagory#", "#SubCatagory#"
   <CFSET LastTopCatagory = TopCatagory>
  </CFIF>
 </CFOUTPUT>);

Goodluck !
eNTRANCE2002 :-)
0
 

Author Comment

by:Max_Davis
ID: 9792036
Hmm, you can't see follow the flow of flow controls very well, eh? That would remove the comma after the first SubCatagory under each TopCatagory, not the last one.

- Max
0
 
LVL 14

Accepted Solution

by:
Renante Entera earned 400 total points
ID: 9792049
If it doesn't work, maybe this is the right code :

 <CFOUTPUT query="q_LinkCatagories">
  <CFIF IsDefined("LastTopCatagory")>
   <CFIF TopCatagory neq LastTopCatagory>); listB.addOptions("#TopCatagory#"</CFIF>
   ,"#SubCatagory#", "#SubCatagory#"
   <CFSET LastTopCatagory = TopCatagory>
  <CFELSE>
   listB.addOptions("#TopCatagory#",
   "#SubCatagory#", "#SubCatagory#"
   <CFSET LastTopCatagory = TopCatagory>
  </CFIF>
 </CFOUTPUT>);

Note : Be careful of the location of the comma ...

Regards!
eNTRANCE2002 :-)
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 14

Expert Comment

by:Renante Entera
ID: 9792069
Actually, I would like to apologize for my first post.  I didn't look carefully to the flow of your code.

Perhaps, the second one might work.  I hope so...

Best wishes!
eNTRANCE2002 :-)
0
 

Author Comment

by:Max_Davis
ID: 9792090
I would like to apologize for doubting your flow following abilities, the second one did indeed work, thank you much.

- Max
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 9792160
Thanks for accepting it and graded it "A".  

I'm glad that your problem has been solved.  Hope to help you again!

See u!
eNTRANCE2002 :-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

778 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