• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

break line <br>

Guest
Jan 27, 2014 Jan 27, 2014

Copy link to clipboard

Copied

<cfset mystring ="Jonh, Doe">

<cfset TheText = replace(mystring, ',', '<br>' , "ALL")>

<cfdump var="#TheText#">

why the results shows Jonh<br>Doe instead of

John

Do

Can anyone pls help?

Thanks

Views

437

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 27, 2014 Jan 27, 2014

Copy link to clipboard

Copied

LATEST

Because you're dumping the object rather than outputting it.

Try <cfoutput>#TheText#</cfoutput>

Here's the technical.

Even though 'John<br>Doe' looks like HTML to you, it is nothing more than a string to ColdFusion.  Text has a mime type of 'text/plain', which the browser iterprets as the actual value itself (John<br>Doe).  So ColdFusion is showing you the actual value of that variable.  Nothing has been output to the buffer for processing.  In order for ColdFusion to output the value of the variable to the buffer so that the browser can attempt to interpret it, you'll need <cfoutput>

Also, this is not a healthy way of writing code (mixing text and HTML).  Browsers do a VERY forgiving job of interpreting what you output as best as they can, but if you're going to output HTML, then wrap the output in the appropriate paragraph tag, ie:

<cfset example = '<p>John<br>Doe</p>' />

<cfoutput>#example#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation