Skip to main content
Inspiring
August 14, 2007
Question

Help for a CF noob

  • August 14, 2007
  • 14 replies
  • 947 views
I want to write a toggle color switch into a CF page with a data table on it
something like this PHP -

<tr<? $toggle=!$toggle; echo($toggle?' class="even"':' class="odd"'; ?>>

What would that look like in CF?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

14 replies

Inspiring
August 14, 2007
That's cool. I may do that, then! Thankee....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
news:f9t8d5$g20$1@forums.macromedia.com...
>A little javascript would do it too:
>
> <script>
> function colorTable() {
> var tableRows =
> document.getElementById('mytable').getElementsByTagName('tr');
> for(var i=0; i<tableRows.length; i++) {
> tableRows .className = (i%2==0) ? 'even':'odd';
> }
> }
> </script>
>
> onload="colorTable()"
>
> Tom
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f9t829$fl7$1@forums.macromedia.com...
>> 50 or so pages, each with 200 - 1000 rows? I don't think so.
>>
>> But this will do the trick, I believe.
>>
>> <cfset toggle = toggle + 1><tr class="#IIF(toggle MOD 2, DE('odd'),
>> DE('even'))#">
>>
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>> news:f9t732$ego$1@forums.macromedia.com...
>>> Does this table have hundreds or thousands of rows? Much easier to apply
>>> class="even" to every other row wtih ctrl>y. It would take about two
>>> minutes to do a few hundred rows.
>>>
>>> Tom
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:f9t6id$dvg$1@forums.macromedia.com...
>>>>I am doing a 'table-wide' find and replace, finding <tr> and replacing
>>>>with <tr<?php ... ?>>.
>>>>
>>>> It works fine in PHP. I just need to know how to do the same in CF.
>>>>
>>>> --
>>>> Murray --- ICQ 71997575
>>>> Adobe Community Expert
>>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>>> ==================
>>>> http://www.dreamweavermx-templates.com - Template Triage!
>>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>>> ==================
>>>>
>>>>
>>>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>>>> news:f9t6ea$drl$1@forums.macromedia.com...
>>>>>
>>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>>> news:f9t5tu$d86$1@forums.macromedia.com...
>>>>>> The heck you say.
>>>>>>
>>>>>> I've done this many times in PHP -
>>>>>>
>>>>>> $toggle=!$toggle; echo($toggle?"odd":"even");
>>>>>
>>>>> The heck you say. That does absolutely nothing unless it's in a
>>>>> loop...or unless you copy/paste into every row. If you are doing that,
>>>>> then this code is identical:
>>>>>
>>>>> class="odd"
>>>>> class="even"
>>>>>
>>>>> Tom
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Inspiring
August 14, 2007
A little javascript would do it too:

<script>
function colorTable() {
var tableRows =
document.getElementById('mytable').getElementsByTagName('tr');
for(var i=0; i<tableRows.length; i++) {
tableRows .className = (i%2==0) ? 'even':'odd';
}
}
</script>

onload="colorTable()"

Tom

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9t829$fl7$1@forums.macromedia.com...
> 50 or so pages, each with 200 - 1000 rows? I don't think so.
>
> But this will do the trick, I believe.
>
> <cfset toggle = toggle + 1><tr class="#IIF(toggle MOD 2, DE('odd'),
> DE('even'))#">
>
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
> news:f9t732$ego$1@forums.macromedia.com...
>> Does this table have hundreds or thousands of rows? Much easier to apply
>> class="even" to every other row wtih ctrl>y. It would take about two
>> minutes to do a few hundred rows.
>>
>> Tom
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:f9t6id$dvg$1@forums.macromedia.com...
>>>I am doing a 'table-wide' find and replace, finding <tr> and replacing
>>>with <tr<?php ... ?>>.
>>>
>>> It works fine in PHP. I just need to know how to do the same in CF.
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.dreamweavermx-templates.com - Template Triage!
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>> ==================
>>>
>>>
>>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>>> news:f9t6ea$drl$1@forums.macromedia.com...
>>>>
>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>> news:f9t5tu$d86$1@forums.macromedia.com...
>>>>> The heck you say.
>>>>>
>>>>> I've done this many times in PHP -
>>>>>
>>>>> $toggle=!$toggle; echo($toggle?"odd":"even");
>>>>
>>>> The heck you say. That does absolutely nothing unless it's in a
>>>> loop...or unless you copy/paste into every row. If you are doing that,
>>>> then this code is identical:
>>>>
>>>> class="odd"
>>>> class="even"
>>>>
>>>> Tom
>>>>
>>>
>>>
>>
>>
>
>


Inspiring
August 14, 2007
50 or so pages, each with 200 - 1000 rows? I don't think so.

But this will do the trick, I believe.

<cfset toggle = toggle + 1><tr class="#IIF(toggle MOD 2, DE('odd'),
DE('even'))#">


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
news:f9t732$ego$1@forums.macromedia.com...
> Does this table have hundreds or thousands of rows? Much easier to apply
> class="even" to every other row wtih ctrl>y. It would take about two
> minutes to do a few hundred rows.
>
> Tom
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f9t6id$dvg$1@forums.macromedia.com...
>>I am doing a 'table-wide' find and replace, finding <tr> and replacing
>>with <tr<?php ... ?>>.
>>
>> It works fine in PHP. I just need to know how to do the same in CF.
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>> news:f9t6ea$drl$1@forums.macromedia.com...
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:f9t5tu$d86$1@forums.macromedia.com...
>>>> The heck you say.
>>>>
>>>> I've done this many times in PHP -
>>>>
>>>> $toggle=!$toggle; echo($toggle?"odd":"even");
>>>
>>> The heck you say. That does absolutely nothing unless it's in a
>>> loop...or unless you copy/paste into every row. If you are doing that,
>>> then this code is identical:
>>>
>>> class="odd"
>>> class="even"
>>>
>>> Tom
>>>
>>
>>
>
>


Inspiring
August 14, 2007
Does this table have hundreds or thousands of rows? Much easier to apply
class="even" to every other row wtih ctrl>y. It would take about two minutes
to do a few hundred rows.

Tom

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9t6id$dvg$1@forums.macromedia.com...
>I am doing a 'table-wide' find and replace, finding <tr> and replacing with
><tr<?php ... ?>>.
>
> It works fine in PHP. I just need to know how to do the same in CF.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
> news:f9t6ea$drl$1@forums.macromedia.com...
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:f9t5tu$d86$1@forums.macromedia.com...
>>> The heck you say.
>>>
>>> I've done this many times in PHP -
>>>
>>> $toggle=!$toggle; echo($toggle?"odd":"even");
>>
>> The heck you say. That does absolutely nothing unless it's in a loop...or
>> unless you copy/paste into every row. If you are doing that, then this
>> code is identical:
>>
>> class="odd"
>> class="even"
>>
>> Tom
>>
>
>


Inspiring
August 14, 2007
That's silly. Putting dynamic code in a static table?

Sorry. In that case the code is as I said:

<cfset toggle = toggle + 1><tr class="#IIF(toggle MOD 2, DE('odd'),
DE('even'))#">

Tom


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9t6id$dvg$1@forums.macromedia.com...
>I am doing a 'table-wide' find and replace, finding <tr> and replacing with
><tr<?php ... ?>>.
>
> It works fine in PHP. I just need to know how to do the same in CF.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
> news:f9t6ea$drl$1@forums.macromedia.com...
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:f9t5tu$d86$1@forums.macromedia.com...
>>> The heck you say.
>>>
>>> I've done this many times in PHP -
>>>
>>> $toggle=!$toggle; echo($toggle?"odd":"even");
>>
>> The heck you say. That does absolutely nothing unless it's in a loop...or
>> unless you copy/paste into every row. If you are doing that, then this
>> code is identical:
>>
>> class="odd"
>> class="even"
>>
>> Tom
>>
>
>


Inspiring
August 14, 2007
I am doing a 'table-wide' find and replace, finding <tr> and replacing with
<tr<?php ... ?>>.

It works fine in PHP. I just need to know how to do the same in CF.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
news:f9t6ea$drl$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f9t5tu$d86$1@forums.macromedia.com...
>> The heck you say.
>>
>> I've done this many times in PHP -
>>
>> $toggle=!$toggle; echo($toggle?"odd":"even");
>
> The heck you say. That does absolutely nothing unless it's in a loop...or
> unless you copy/paste into every row. If you are doing that, then this
> code is identical:
>
> class="odd"
> class="even"
>
> Tom
>


Inspiring
August 14, 2007

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9t5tu$d86$1@forums.macromedia.com...
> The heck you say.
>
> I've done this many times in PHP -
>
> $toggle=!$toggle; echo($toggle?"odd":"even");

The heck you say. That does absolutely nothing unless it's in a loop...or
unless you copy/paste into every row. If you are doing that, then this code
is identical:

class="odd"
class="even"

Tom


Inspiring
August 14, 2007
The heck you say.

I've done this many times in PHP -

$toggle=!$toggle; echo($toggle?"odd":"even");

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
news:f9t51p$c9p$1@forums.macromedia.com...
> If it is a static table then the PHP code won't do anything either. A
> toggle only works on a dynamic table where a loop is involved.
>
> Tom
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f9suis$4vp$1@forums.macromedia.com...
>> Preferably just the way I showed in my original PHP snippet.
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:f9su9i$4jp$1@forums.macromedia.com...
>>> There is no loop. It's a static data table. I need it all to be self
>>> contained in a single statement.
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.dreamweavermx-templates.com - Template Triage!
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>>> ==================
>>>
>>>
>>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>>> news:f9strn$46a$1@forums.macromedia.com...
>>>>
>>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>>> news:f9sptl$t2g$1@forums.macromedia.com...
>>>>> There is no recordset. It's a static page in a curiously CF site (all
>>>>> to only use cfincludes) that I have been asked to 'fix'. So - would
>>>>> it be -
>>>>>
>>>>> <tr class="#IIF(toggle/mod2, DE('odd'), DE('even'))#">#toggle =
>>>>> !toggle#
>>>>
>>>> Ah, you said "data table", which led me to believe there was data in
>>>> it. :-)
>>>>
>>>> No, it would be:
>>>>
>>>> Initialize the toggle:
>>>>
>>>> <cfset toggle = 0>
>>>>
>>>> Inside the loop, increment it:
>>>>
>>>> <cfset toggle = toggle + 1>
>>>>
>>>> Then in the tag:
>>>>
>>>> <tr class="#IIF(toggle MOD 2, DE('odd'), DE('even'))#">
>>>>
>>>> Tom
>>>>
>>>
>>>
>>
>>
>
>


Inspiring
August 14, 2007
If it is a static table then the PHP code won't do anything either. A toggle
only works on a dynamic table where a loop is involved.

Tom


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9suis$4vp$1@forums.macromedia.com...
> Preferably just the way I showed in my original PHP snippet.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f9su9i$4jp$1@forums.macromedia.com...
>> There is no loop. It's a static data table. I need it all to be self
>> contained in a single statement.
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
>> news:f9strn$46a$1@forums.macromedia.com...
>>>
>>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>>> news:f9sptl$t2g$1@forums.macromedia.com...
>>>> There is no recordset. It's a static page in a curiously CF site (all
>>>> to only use cfincludes) that I have been asked to 'fix'. So - would it
>>>> be -
>>>>
>>>> <tr class="#IIF(toggle/mod2, DE('odd'), DE('even'))#">#toggle =
>>>> !toggle#
>>>
>>> Ah, you said "data table", which led me to believe there was data in it.
>>> :-)
>>>
>>> No, it would be:
>>>
>>> Initialize the toggle:
>>>
>>> <cfset toggle = 0>
>>>
>>> Inside the loop, increment it:
>>>
>>> <cfset toggle = toggle + 1>
>>>
>>> Then in the tag:
>>>
>>> <tr class="#IIF(toggle MOD 2, DE('odd'), DE('even'))#">
>>>
>>> Tom
>>>
>>
>>
>
>


Inspiring
August 14, 2007
Preferably just the way I showed in my original PHP snippet.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f9su9i$4jp$1@forums.macromedia.com...
> There is no loop. It's a static data table. I need it all to be self
> contained in a single statement.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Tom Muck" <tommuck@NO-SPAM-hotmail.com> wrote in message
> news:f9strn$46a$1@forums.macromedia.com...
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:f9sptl$t2g$1@forums.macromedia.com...
>>> There is no recordset. It's a static page in a curiously CF site (all
>>> to only use cfincludes) that I have been asked to 'fix'. So - would it
>>> be -
>>>
>>> <tr class="#IIF(toggle/mod2, DE('odd'), DE('even'))#">#toggle = !toggle#
>>
>> Ah, you said "data table", which led me to believe there was data in it.
>> :-)
>>
>> No, it would be:
>>
>> Initialize the toggle:
>>
>> <cfset toggle = 0>
>>
>> Inside the loop, increment it:
>>
>> <cfset toggle = toggle + 1>
>>
>> Then in the tag:
>>
>> <tr class="#IIF(toggle MOD 2, DE('odd'), DE('even'))#">
>>
>> Tom
>>
>
>