Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
CFMadness #1
<cfscript> autocaps problem </cfscript> - betcha can't fix this!
First, I'll tell you up front that I am clueless when it comes to
cfscript. So I apologize if this question is off topic.
I have a nice little <cfscript> that capitalizes selected fields in my
form submissions. It looks like this:
<cfscript>
function CapFirst(str) {
var result = Trim(str);
var wordCount = ListLen(result," ");
var ProperString = "";
for(i=1;i LTE wordCount;i=i+1) {
ProperString = ProperString & " " & UCase(Left(ListGetAt(result,i,"
"),1)) & LCase(RemoveChars(ListGetAt(result,i," "),1,1));
} ProperString = Trim(ProperString);
return ProperString;}
</cfscript>
Then I display the results as follows:
#CapFirst(Session.Customer.Fir*stName)#
It works fantastic, except for some reason on my final form submission,
if someone enters an apostrophe in the field, it wants to repeat it 8
times. So the name "O'Brien" will look like "O''''''''brien". I can
live with the second character being lowercase, but the repeating
apostrophe's have to go. Why there is 8, I do not know. I am
capitalizing 7 fields, but it is not looping over them. So I'm not sure
why it is doing this.
Also, the amount of apostrophes returned depends upon the number of
words in that field. So "Bob's and Ed's" would appear as
Bob''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''s
And Ed''''''''''''''''s". (64 and 16 - multiples of 8)
Kinda strange! Any ideas?? Maybe adding an "if" statement to ignore the
apostrophe's??
CFMadness Guest
-
looping over a structure using cfscript
Hi, I am passing form variables to a function. What i want is to be abled to loop throught the form variables which is a structure and then for... -
cfscript auto capitalize help
Hey you cfscript experts! I have an auto-capitalize script that I use on my forms for capitalizing names and such. If the user enters ALLCAPS,... -
cfscript
since i cannot find the cf and java integration thread, gues i will post this here: i wrote a cfm with cfscript that utilizes java which connects... -
cfscript and variables
I'm using cfscript against a COM object. In VB the paramater is passed like: Set oSegment = oTransactionset.CreateDataSegment('BEG')... -
vbscript to cfscript
I'm trying to assign a value to an object. I have an example in asp that works and I'm trying to get it to work in cfscript. Here's the vbscript: ...



Reply With Quote

