Question
Force UpperCase, with exclusions
Greetings,
I am a low level CF programmer and have a problem to solve a bit above my skill level. Can anyone help add to this code to solve the problem.
I have the following CF code, that pulls from a db the news for a client's news page. The coding forces the news title to display the first letter of each word in UPPERCASE. BUT, there are a few words that I'd like to be excluded from this, and left as all upppercase (ex. USA..... not Usa). Here's the code I have now:
<cfoutput query="rsGetNews">
<cfset jon="rsGetNews.newstitle">
<cfscript> function ucwordss(jon) { jon = lcase(jon); wordsCapFirst = ""; for (i=1; i LTE ListLen(jon," "); i=i+1) { jonTemp = ListGetAt(jon,i," "); jonTemp = ucase(left(jonTemp,1)) & mid(jonTemp,2,len(jonTemp)-1); wordsCapFirst = ListAppend(wordsCapFirst,jonTemp," "); } return wordsCapFirst; } </cfscript>
#ucwordss(rsGetNews.newstitle)#
</cfoutput>
How do I rewrite this so that USA, CANADA, and ENGLAND are not given lowercase letters?
Many thanks,
Stephen
Tallahassee, FL
</a></li>
</cfoutput>
I am a low level CF programmer and have a problem to solve a bit above my skill level. Can anyone help add to this code to solve the problem.
I have the following CF code, that pulls from a db the news for a client's news page. The coding forces the news title to display the first letter of each word in UPPERCASE. BUT, there are a few words that I'd like to be excluded from this, and left as all upppercase (ex. USA..... not Usa). Here's the code I have now:
<cfoutput query="rsGetNews">
<cfset jon="rsGetNews.newstitle">
<cfscript> function ucwordss(jon) { jon = lcase(jon); wordsCapFirst = ""; for (i=1; i LTE ListLen(jon," "); i=i+1) { jonTemp = ListGetAt(jon,i," "); jonTemp = ucase(left(jonTemp,1)) & mid(jonTemp,2,len(jonTemp)-1); wordsCapFirst = ListAppend(wordsCapFirst,jonTemp," "); } return wordsCapFirst; } </cfscript>
#ucwordss(rsGetNews.newstitle)#
</cfoutput>
How do I rewrite this so that USA, CANADA, and ENGLAND are not given lowercase letters?
Many thanks,
Stephen
Tallahassee, FL
</a></li>
</cfoutput>