Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

No last comma

Posted on 2003-11-20
6
Medium Priority
?
299 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 1600 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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 video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

772 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