Solved

single & double quotes not outputing

Posted on 2010-11-16
8
379 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_
Comment Utility
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
Comment Utility
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_
Comment Utility
No the whole value passed to javascript has to be wrapped in JSStringFormat()

ie
    onMouseover="showtext('<b>#JSStringFormat(rsWorks.Title)#</b>'  )" ......
0
 

Author Comment

by:phillystyle123
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
>> 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_
Comment Utility
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
Comment Utility
perfecto! thanks for the help!
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Welcome :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now