We help IT Professionals succeed at work.

Coldfusion field in html title attribulte stopping at quotes

cbeverly
cbeverly asked
on
I am trying to add a title attribute including a field in a database but it stops when it encounters a quote. The line of code is below but the problem is specifically with  title="#BookTitleDisplay#
The title that is having problems is: Spanish Harlem ("American Scene" series, No. 3)
It displays as; Spanish Harlem (
Stopping when it reaches the quotes.

<a href="/visit/stores/online_redo/index_shop_ault.cfm" class="nounderline"><img src="/visit/images/#CoverImageFilename#" alt="#BookTitleDisplay#" title="#BookTitleDisplay#, <cfif HardcoverRetailPrice is not ''>#HardcoverRetailPrice# hardcover</cfif><cfif HardcoverRetailPrice is not '' and SoftcoverRetailPrice is not ''>,</cfif> <cfif SoftcoverRetailPrice is not ''>#SoftcoverRetailPrice# softcover</cfif>"></a>                  
Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2015
Commented:
Try HTMLEditFormat()

      <img src="/visit/images/#CoverImageFilename#"
            alt="#HTMLEditFormat(BookTitleDisplay)#" ...
BRONZE EXPERT

Commented:
add urlEncodedFormat() to format the value...

alt="#urlEncodedFormat(bookTitleDisplay)#"
SILVER EXPERT
Most Valuable Expert 2015

Commented:
No, it needs to be html escaped. URL escaping the string would just convert the quotes to %22, spaces to %20, etc...
BRONZE EXPERT

Commented:
oh right, that makes sense.

Author

Commented:
Thank you!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.