Ask a Question related to Macromedia ColdFusion, Design and Development.
-
jay54321 #1
Trouble using Replace() function in CFN file
I don't do much scripting in coldfusion besides some of the very basics for
trasfering info from the database, so I'm not sure how to write this....
This is what I've put together so far, which of course does not work. Any
help would be appreciated, I've been at it a while now.
So both TextBlock1 and TextBlock2 are fields which I'm taking from the
database, and trying to do a Replace, to take out the \r in them, since in my
flash front end, I'm getting multiple carriage returns within the text blocks.
So if anyone knows the syntax issues I'm having with the Replace function
below, please let me know.
Thanks in advance
................previous info left out...........
SELECT *
FROM pdTable1
WHERE TestID='#ID1#'
LIMIT #OrderNum#,1
</cfquery>
<cfif IsDefined("TextBlock1")>
Replace(#TextBock1#,"\r","","ALL")#
<cfoutput>#TextBock1_mod#</cfoutput>
</cfif>
<cfif IsDefined("TextBlock2")>
Replace(#TextBock2#,"\r","","ALL")#
<cfoutput>#TextBock2_mod#</cfoutput>
</cfif>
jay54321 Guest
-
Replace function
Please help, I want to replace a string within field in a table with a nother string. I am using the replace function but I am doing something... -
Replace string query - double trouble!
UPDATE `tableName` SET `fieldName` = REPLACE(fieldName,"stringOne","stringTwo") I use the above code to strip strings from my table, and most of... -
Search & Replace Function?
I have some textfield that users will enter data into on my web site and then I'll use php and write it to mysql - for security purposes, is there... -
Using Replace function to remove two different characters
I'm using replace function to strip 0s from a particular string: <%=replace(rs1("racelength"),"0","''"%> but I need to also strip empty spaces... -
Text Replace function
Hi - I'm using the replace function to hilite search words in text which is returned. However, as the text which is being searched also includes... -
CRidgway #2
Re: Trouble using Replace() function in CFN file
Unless the "\r" is actually stored in the database as a litteral string, you
will need to search and replace chr(10) and chr(13)...
give this a try:
<cfset newLine = chr(10) & chr(13)>
<cfoutput query="queryName">
<cfset TextBock1_mod = Replace(TextBock1, newLine ,"" ,"ALL")>
#TextBock1_mod#
<cfset TextBock2_mod = Replace(TextBock2, newLine ,"" ,"ALL")>
#TextBock2_mod#
</cfoutput>
CRidgway Guest
-
jay54321 #3
Re: Trouble using Replace() function in CFN file
I'm still having trouble incorporating the code which was posted....... This
is what I have so far...........
I'm pretty unfamiliar with CFN, where I'm not sure the best place to put the
code which was posted. I'm trying various things, but so far nothing. The
location it is now, still outputs the old information, and if I put it anywhere
else it doesn't work at all. Thanks again in advance.
<cfsetting enablecfoutputonly="YES">
<cfset EVendorID1 = form.EVendorID1>
<cfset OrderNum = form.OrderNum>
<cfset newLine = chr(10) & chr(13)>
<cfquery name="PCheck" datasource="EW" timeout="10" debug username="root"
password="abc">
SELECT *
FROM product1
WHERE VendorPD1='#EDEVendorID1#'
LIMIT #OrderNum#,1
</cfquery>
<CFOUTPUT QUERY="PCheck">
<cfset TextBlock1_mod = Replace(TextBlock1, newLine ,"" ,"ALL")>
<cfset TextBlock2_mod = Replace(TextBlock2, newLine ,"" ,"ALL")>
<!---<cfif (#Pass#) IS (#VenPass1#)>--->
<cfset returnToFlash = "&writing=Acq&, &TimeOfOrder=#TimeSTMP1#&">
<!---</cfif>--->
</CFOUTPUT>
<!---<cfset returnToFlash = "&writingTEMP=NA&">--->
<!--- FlashOutput contains the string that will be sent back to Flash--->
<cfprocessingdirective suppresswhitespace="Yes">
<cfoutput>
#returnToFlash#
</cfoutput>
</cfprocessingdirective>
jay54321 Guest
-
MikerRoo #4
Re: Trouble using Replace() function in CFN file
There is a typo in the setting of newline.
It should be:
<cfset newLine = chr(13) & chr(10)>
If you speak hex, it's easy to remember as DOA (0x0D0A) :P .
To remove all doubt, you can also remove the \r and \n seperately like this:
<cfset TextBlock1_mod = Replace (TextBlock1, Chr(13),"" ,"ALL")>
<cfset TextBlock2_mod = Replace (TextBlock2, Chr(13),"" ,"ALL")>
<cfset TextBlock1_mod = Trim (Replace (TextBlock1, Chr(10),"" ,"ALL"))>
<cfset TextBlock2_mod = Trim (Replace (TextBlock2, Chr(10),"" ,"ALL"))>
(I added Trim() which may also be needed here.)
Regards,
-- MikeR
MikerRoo Guest



Reply With Quote

