No offense Jeff, but, I love it when people make things more complicated
than they need to be.

<cfset newstring = "">
<CFSET TargetString = "Now is the time for all good men and WOMEN.">

<cfloop index="ii" list="#TargetString#" delimiters=" ">

<cfset newstring = newstring & " " & UCase(Left(ii, 1)) & LCase(Mid(ii, 2,
len(ii)-1))>

</cfloop>

<cfoutput>#newstring#</cfoutput>

That works like a charm, gives me "Now Is The Time For All Good Men And
Women.".  Just replace the var "TargetString" with your form field.  If you
need to do it for multiple fields let me know.  I can build that loop for
you as well.

--K

-----Original Message-----
From: Jeff Bevill [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 26, 2000 6:50 AM
To: CF-Talk
Subject: RE: Capitalize First Letter of Each Word


John McKown,

Here ya go man.  I only had about 10 mins to write this, hope it works. :)

<!--- l33t w3rd fixer v1.0 --->
<!--- Jeff Bevill - [EMAIL PROTECTED] --->

<cfset Variable="UnBeLiEvAbLe">

<cfif isDefined("Variable") and Len(Variable) GT 0>
        <cfset in="1">
        <cfset out="0">
        <cfset word_state=out>

        <cfset NewStr="">
        <cfset is_space=false>
        <cfloop index=i from=1 to=#Len(Variable)#>
                <cfset Character=Mid(Variable, i, 1)>

                <cfif Character is " ">
                        <cfset word_state=out>
                        <cfset NewStr=NewStr & Character>
                <cfelseif Asc(Character) GE Asc("a") and Asc(Character) LE
Asc("z") and
word_state EQ out>
                        <cfset word_state=in>
                        <cfset NewStr=NewStr & UCase(Character)>
                <cfelseif Asc(Character) GE Asc("A") and Asc(Character) LE
Asc("Z") and
word_state EQ in>
                        <cfset NewStr=NewStr & LCase(Character)>
                <cfelse>
                        <cfset word_state=in>
                        <cfset NewStr=NewStr & Character>
                </cfif>

        </cfloop>

        <cfset Variable=NewStr>
</cfif>

<cfoutput>#Variable#</cfoutput>

Jeff Bevill

-----Original Message-----
From: John McKown [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 26, 2000 6:35 AM
To: CF-Talk
Subject: Capitalize First Letter of Each Word


Can someone share a script that will capitalize the
first letter of every word entered into a form field?

John McKown, VP Business Services
Delaware.Net, Inc.
30 Old Rudnick Lane, Suite 200 Dover, DE 19901
email: [EMAIL PROTECTED]
phone: 302-736-5515
fax: 302-736-5945
icq: 1495432



----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]

----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to