Link to home
Create AccountLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

single & double quotes not outputing

When I have a single or dbl quote in my table, the field won't output

so
16' x 20', or 16" x 20" doesn't output- no error, but no output.


query:

<cfquery name="rsWorks" datasource="dranoffDSN">
SELECT AutoArtID, artworknew.ArtistID, Title, Date, sm, DescriptionWhole, WebDescriptionLine1, 
WebDescriptionLine2, WebDescriptionLine3, WebDescriptionLine4, WebDescriptionLine5, 
WebDescriptionLine6, WebDescriptionLine7, FirstName, LastName FROM artworknew, artistsnew WHERE artworknew.ArtistID=#URL.ArtistID# and artworknew.ArtistID=artistsnew.ArtistID and ArtistPage="1" ORDER BY ArtistPageOrder asc, AutoArtID desc
</cfquery>

output:

<CFOUTPUT QUERY="rsWorks" startrow="#StartRow_rsWorks#" maxrows="#MaxRows_rsWorks#"><div class="artworkWrap"><div class="artworkContainer"><a class="imgPop" href="artwork_detail.cfm?AutoArtID=#AutoArtID#&ArtistID=#ArtistID#&PageNum_newaqimages=#currentRow#" onMouseover="showtext('<b>#rsWorks.Title#</b>....

Open in new window

Avatar of _agx_
_agx_
Flag of United States of America image

If you're using it in javascript, you need to escape special characters.  Try wrapping it in JSStringFormat()
http://livedocs.adobe.com/coldfusion/8/functions_in-k_46.html
Avatar of phillystyle123

ASKER

can i just do this:

<cfoutput>JSStringFormat(#rsWorks.Title#)</cfoutput>

i know i'm doing something wrong  -it's not outputting
No the whole value passed to javascript has to be wrapped in JSStringFormat()

ie
    onMouseover="showtext('<b>#JSStringFormat(rsWorks.Title)#</b>'  )" ......
that's exactly what i'm doing:

 
<CFOUTPUT QUERY="rsWorks" startrow="#StartRow_rsWorks#" maxrows="#MaxRows_rsWorks#"><div class="artworkWrap"><div class="artworkContainer"><a class="imgPop" href="artwork_detail.cfm?AutoArtID=#AutoArtID#&ArtistID=#ArtistID#&PageNum_newaqimages=#currentRow#" onMouseover="showtext('<b>JSStringFormat(#rsWorks.Title#)</b><cfif '#rsWorks.Date#' eq ""><cfelse><br></cfif>#rsWorks.Date#<cfif '#rsWorks.WebDescriptionLine1#' eq ""><cfelse><br></cfif>JSStringFormat(#rsWorks.WebDescriptionLine1#)<cfif '#rsWorks.WebDescriptionLine2#' eq ""><cfelse><br></cfif>JSStringFormat(#rsWorks.WebDescriptionLine2#)<cfif '#rsWorks.WebDescriptionLine3#' eq ""><cfelse><br></cfif>JSStringFormat(#rsWorks.WebDescriptionLine3#)<cfif '#rsWorks.WebDescriptionLine4#' eq ""><cfelse><br></cfif>JSStringFormat(#rsWorks.WebDescriptionLine4#)<cfif '#rsWorks.WebDescriptionLine5#' eq ""><cfelse><br></cfif>JSStringFormat(#rsWorks.WebDescriptionLine5#)')" onMouseout="hidetext()"><img src="http://69.24.71.19/newsite/images/sm/#rsWorks.sm#" border="0"></a></div><div id="artworkCaption">#PreserveSingleQuotes(rsWorks.Title)#<br /><a class="white" href="artwork_detail.cfm?AutoArtID=#AutoArtID#&ArtistID=#ArtistID#&PageNum_newaqimages=#currentRow#"><strong>Details</strong></a></div></div></cfoutput>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Here's a crude sample.  Notice how an alert appears on mouseover?
<cfset rsWorks.Title = "16' x 20'">
<cfset rsWorks.Stuff = "foo">
<script>
	function showtext(str) {
		alert(str);
	}
</script>
<cfoutput>
	<!--- generate the string for the javascript function --->
	<cfsavecontent variable="jsText">
	Title = #rsWorks.Title#
	Stuff = #rsWorks.Stuff#
	</cfsavecontent>
	<a href="##" onMouseOver="showtext('#JSStringFormat(Trim(jsText))#')">Test</a>
</cfoutput>

Open in new window

perfecto! thanks for the help!
Welcome :)