Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6362955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:58:27+00:00 2026-05-24T23:58:27+00:00

I am using ColdFusion 9. I can’t find a means to successfully output a

  • 0

I am using ColdFusion 9.

I can’t find a means to successfully output a single quote into a text field.

I create form fields using a CFSCRIPT user defined function. (I’ve minimized the options for the sake of simplicity for this example.)

When my output contains a single quote, the text field gets totally screwed up, be sure to run the example and view the HTML. I have tried using PreserveSingleQuotes() every conceivable way possible.

// USE EITHER STRING
MyString = "This string works fine.";
MyString = "This single quote's the problem!";
writeOutput(createInputBox(MyString));

// CREATE TEXT INPUT
function createInputBox(Value) {
    LOCAL.Properties = " value='#preserveSingleQuotes(ARGUMENTS.Value)#'";
    LOCAL.Item = "<input size='50' type='text' #LOCAL.Properties# />";
    return LOCAL.Item;
}

Do you know of a solution?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANSWER

Get rid of the preserveSingleQuotes() function, as it does nothing outside of a SQL block. (Thanks Adam!).

LOCAL.Properties = " value='#ARGUMENTS.Value#'";

Then, get rid of the single quotes and replaced with escaped double quotes:

LOCAL.Properties = " value=""#ARGUMENTS.Value#""";

This will still choke on strings like this though:

MyString = "This is my F#@'''""$":""ing  problem!";

So, add the htmlEditFormat() function like this:

LOCAL.Properties = " value=""#htmlEditFormat(ARGUMENTS.Value)#""";

Thanks for the help!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:58:28+00:00Added an answer on May 24, 2026 at 11:58 pm

    A single quote should not give you a problem in an attribute value in HTML, unless:
    * you’re not quoting the attribute values, eg:

    <input value=#myvar#>
    

    The solution here is to quote your attributes, eg:

    <input value="#myvar#">
    

    or
    * you are quoting your attributes, but are using single quotes :

    <input value='#myVar#'>
    

    Will end up being:

    <input value='value with a ' in it'>
    

    This – of course is invalid mark-up: the browser sees the value as ‘value with a ‘, and the rest of it is just garbage.

    If you need to do this:
    * switch to using double-quote delimiters
    * use htmlEditFormat() around your variable value (this will escape embedded double-quotes).

    To troubleshoot this sort of thing, ALWAYS look at the HTML source. This will help you work out what’s going on.

    NB: to everyone mentioning preserveSingleQuote(): this function does NOTHING outside of a CFQUERY block. So it’s not going to help here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single
How can dynamic HTML be put into a PDF using ColdFusion? This is in
I'm trying to create pagination for search results using MySQL and ColdFusion. My intention
Can anyone expound on disadvantages, if there are any, to using a ColdFusion development
When using ColdFusion ORM where you have several tables with relationships can I bind
I am using Coldfusion to create a basic Excel spreadsheet. I build a table,
I am trying to load a CSV file into an array using ColdFusion (version
How do I post a form using jQuery.post() to a Coldfusion.cfc method and return
How can I get the subdomain of a URL using Coldfusion? For example, say
I'm using Coldfusion. I want to concatenate two strings into the same struct key,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.