Solved

single & double quotes not outputing

Posted on 2010-11-16
8
382 Views
Last Modified: 2013-12-24
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

0
Comment
Question by:phillystyle123
  • 5
  • 3
8 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34150434
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
0
 

Author Comment

by:phillystyle123
ID: 34150501
can i just do this:

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

i know i'm doing something wrong  -it's not outputting
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34150663
No the whole value passed to javascript has to be wrapped in JSStringFormat()

ie
    onMouseover="showtext('<b>#JSStringFormat(rsWorks.Title)#</b>'  )" ......
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:phillystyle123
ID: 34150755
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

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 34150986
>> JSStringFormat(#rsWorks.Title#)

No, it's not.  You're using it around each variable separately with _no_ # signs.  It needs to be around the _whole_ value you're passing into the javascript function AND you need # signs around it.  Otherwise CF won't even know it's a function.

Also, all those nested cfif's are *really* confusing. I'd suggest you construct the string first _then_ pass it into your javascript function.

<cfoutput ...>
      <cfsavecontent variable="jsText">
      <b>#rsWorks.Title#</b>
      <cfif rsWorks.Date neq "">
            ... more stuff here....
      </cfif>
      </cfsavecontent>
      <a href="##" onMouseover="showtext('#JSStringFormat(jsText)#');"  .. >
</cfoutput>
      



0
 
LVL 52

Expert Comment

by:_agx_
ID: 34151041
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

0
 

Author Closing Comment

by:phillystyle123
ID: 34151116
perfecto! thanks for the help!
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34152524
Welcome :)
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question