Either that or...
------------------------------------------------------
<!--- Sentence Capitaliser --->
<!--- Paul Johnston --->
<!--- to capitalise all words in a sentence --->
<cfset Variable="YoUr UnBeLiEvAbLe">
<cfoutput><br>#Variable#</cfoutput><br>
<!--- put the sentence into an array (convert from a list of space delimited
words) --->
<cfset text = ListToArray(variable, " ")>
<!--- create new array to hold all changed words --->
<cfset new_text = ArrayNew(1)>
<!--- loop over the array (each word) --->
<cfloop from="1" to="#ArrayLen(text)#" index="i">
<!--- get length of variable --->
<cfset length = len(text[i])>
<!--- put first letter as capital into variable --->
<cfset first_letter = UCase(Left(text[i],1))>
<!--- if length of word is greater than one (it could be "A"), then
lower case the rest --->
<cfif length gt 1>
<!--- find length of rest of word --->
<cfset rest_length = length - 1>
<!--- lower case it --->
<cfset rest = Lcase(Right(text[i],rest_length))>
</cfif>
<!--- set new_text to the changed word --->
<cfset new_text[i] = first_letter & rest>
</cfloop>
<!--- loop over new array and output --->
<cfloop from="1" to="#ArrayLen(new_text)#" index="j">
<cfoutput>#new_text[j]#</cfoutput>
</cfloop>
------------------------------------------------------
The loop is unnecessary for only one word, but this will capitalise ALL
words in one sentence.
Paul
> -----Original Message-----
> From: Jeff Bevill [mailto:[EMAIL PROTECTED]]
> Sent: 26 October 2000 14:50
> 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]