Solved

No last comma

Posted on 2003-11-20
6
289 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

11 Experts available now in Live!

Get 1:1 Help Now