Solved

No last comma

Posted on 2003-11-20
6
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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