Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

single & double quotes not outputing

Posted on 2010-11-16
8
Medium Priority
?
399 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
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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