?
Solved

single & double quotes not outputing

Posted on 2010-11-16
8
Medium Priority
?
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

 

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 2000 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

Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

Question has a verified solution.

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

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

764 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