OK, there are about a million ways to do both of these tasks. Here is one of each:
====================================
ALTERNATING ROW COLOR:
-- easiest to use a CSS class; can alway use a hex value, as well. In this example, 
issueEven and issueOdd are two classes; same except different background colors:
        <cfloop query="qGetResults">
                <!--- figure out row color --->
                <cfif #currentRow# MOD 2 EQ 0>
                        <cfset rowColor = "issueEven">
                <cfelse>
                        <cfset rowColor = "issueOdd">
                </cfif>
                <tr class="#rowColor#">.............
=====================
CREDIT CARD NUMBER VALID:

Here's a JS routine for this that is from shift4.com (NOTE: code can be used as long 
as copyright remains in the code; this is NOT my code); put code in custom tag and 
call it with this call:

<cf_testcardnumber result="result" cardnumber=#howEverYouHaveCCNumber#>

WHICH CALLS THE FOLLOWING CUSTOM TAG: (named testcardnumber.cfm)


<!---

        TestCardNumber.cfm



        Custom tag to perform a simple validation and card type check.



        Parameters:

                name            See "result" below

                result          The variable name to place the results (name can be 
used instead of

                                        result but will require additional coding if 
you ever decide to use

                                        cfmodule)

                cardnumber      The card number to check

                options         Comma separated list of tag options -- currently, only 
supported

                                        option is NoLuhn which tells the tag to not 
perform the luhn-mod-10

                                        check on the card number



        Returns:

                ?? = the card is not valid

                AX = American Express

                DC = Diners Club

                JC = JCB

                MC = MasterCard

                NS = Novus (Discover)

                VS = VISA



        Copyright (C) 2002 Shift4 Corporation, Las Vegas, NV, USA (www.shift4.com)  -- 
 ALL

        RIGHTS RESERVED. This code comes with no warranty expressed or implied. Use at 
your

        own risk. Permission is given to freely use and distribute this file (tag) 
provided

        this copyright notice and disclaimer are not modified or removed.

--->



<cfif not IsDefined("ATTRIBUTES.CardNumber")>

        <cfabort showerror="Error calling cf_TestCardNumber: CardNumber parameter must 
be specified.">

</cfif>



<cfparam name="ATTRIBUTES.Name" default="">

<cfparam name="ATTRIBUTES.Result" default="#ATTRIBUTES.Name#">

<cfif ATTRIBUTES.Result is "">

        <cfabort showerror="Error calling cf_TestCardNumber: Name or Result parameter 
must be specified.">

</cfif>

<cfparam name="ATTRIBUTES.Options" default="">



<cfscript>

        ccnum = REReplace(ATTRIBUTES.CardNumber,"[^0-9]","","ALL");

        cctyp = "??";

        cclen = Len(ccnum);



        if (cclen GTE 13 and cclen LTE 16) {

                ccval8 = Val(Left(ccnum,8));

                CRLF = Chr(13) & Chr(10);

                cardranges =    "AX,15,34000000,34999999"

                        & CRLF &        "AX,15,37000000,37999999"

                        & CRLF &        "DC,14,30000000,30999999"

                        & CRLF &        "DC,14,36000000,36999999"

                        & CRLF &        "DC,14,38000000,38999999"

                        & CRLF &        "DC,14,39000000,39009999"

                        & CRLF &        "DC,15,20140000,20149999"

                        & CRLF &        "DC,15,21490000,21499999"

                        & CRLF &        "JC,16,30880000,30949999"

                        & CRLF &        "JC,16,30960000,31029999"

                        & CRLF &        "JC,16,31120000,31209999"

                        & CRLF &        "JC,16,31580000,31599999"

                        & CRLF &        "JC,16,33370000,33499999"

                        & CRLF &        "JC,16,35280000,35899999"

                        & CRLF &        "MC,16,50000000,59999999"

                        & CRLF &        "NS,16,60110000,60110999"

                        & CRLF &        "NS,16,60112000,60119999"

                        & CRLF &        "VS,13,40000000,49999999"

                        & CRLF &        "VS,16,40000000,49999999";



                for (i=1; i LTE ListLen(cardranges,CRLF); i=i+1) {

                        range = ListGetAt(cardranges,i,CRLF);

                        if (ListLen(range) EQ 4) {

                                if (cclen EQ Val(ListGetAt(range,2))) {

                                        if (ccval8 GTE Val(ListGetAt(range,3)) and 
ccval8 LTE Val(ListGetAt(range,4))) {

                                                // good card as far as ranges go, do 
luhn-mod-10 check for safety

                                                if 
(ListFindNoCase(ATTRIBUTES.Options,"NoLuhn") EQ 0) {

                                                        luhn = 0;

                                                        mult = 1;

                                                        for (i=cclen; i GTE 1; i=i-1) {

                                                                tmp = Mid(ccnum,i,1) * 
mult;

                                                                while (tmp GT 0) {

                                                                        luhn = 
luhn+(tmp mod 10);

                                                                        tmp = 
Int(tmp/10);

                                                                }

                                                                mult = 3-mult;

                                                        }

                                                        luhn = (10-(luhn mod 10)) mod 
10;

                                                        if (luhn EQ 0)

                                                                cctyp = 
ListGetAt(range,1);

                                                } else

                                                        cctyp = ListGetAt(range,1);

                                                break;

                                        }

                                }

                        }

                }

        }

</cfscript>

        

<cfset "CALLER.#ATTRIBUTES.Result#" = cctyp>

===================================================


>I know this has probably been asked numerous times, but I wonder if 
>anyone has the CF code that alternates color on rows in a table?
>
>Also, does anyone have the CF(?) code that checks/verifies whether a 
>credit card number is entered correctly?
>
>Thanks as usual.
>
>Robert O.
HWW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Reply via email to