Solved

No last comma

Posted on 2003-11-20
6
292 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CGI takes almost 2 minutes to load using thttpd 20 44
Problem to Eclipse 16 117
Intranet and Kerberos Authentication (not sharepoint!) 8 117
WEB Farm 6 64
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now