Coldfusion, Jquery and special characters

I am using jquery to populate a form.   Here is the way that I am doing it:

<script type="text/javascript">
      $(document).ready(function(){
            <cfoutput query="qry_sel_info">
                  $("##notes").val("#notes#");
            </cfoutput>
       });
</script>

The problem I'm running into is special characters.  Users are entering single quotes (which in this case works), double quotes, and hitting <enter> after lines.  How can I fix this so it will show all the special characters without having problems.  

I'm not too good at regular expressions, but I gave it a shot and here is what I've tried so far:

<cfset aNote = #REReplace(admin_note,"([\'\""])","\\\1", "all")#>
$("##notes").val("#anotes#");

This works to a point.  The problem is that in my textarea it shows:
&quot;This is a 'test'&quot;

The single quotes work the way I want, but I don't want &quot;, i actually want the " to show.  Plus I have no idea what to do with a <enter>

Another issue is that I have a TON of fields that this effects.  What is the easiest way to do this without having to use cfset on every field?  I would assume a function...but i'm fairly new to jquery.  

Thanks in advance for your help
LVL 5
trifecta2kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
(no points ..)

I haven't tested it, but I normally use jsStringFormat which properly escapes input for use in javascript.


Plus I have no idea what to do with a <enter>
Depends on the field type.  Most html elements (except maybe textarea) can't display ascii new lines ie chr(10). If you want to preserve/display them, convert them to html line breaks instead ie <br>.  

So maybe something like    

            $("##notes").val( '#jsStringFormat( replace(notes, chr(10), "<br>", "all") )#' );

Another issue is that I have a TON of fields that this effects.

Then you might consider creating a wrapper function, and call it instead.
0
trifecta2kAuthor Commented:
Looks like jsStringFormat works by itself.  I don't need the chr(10) stuff.  jsStringFormat already escapes newline.  I guess that's all I was looking for.  Thanks!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_agx_Commented:
Ok, kewl. I couldn't remember off the top of my head :)
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

trifecta2kAuthor Commented:
agx..you wrote no points...how do I accept this as a solution without giving you points?
0
_agx_Commented:
I think you can accept one of your own comments as an answer.
0
trifecta2kAuthor Commented:
OK.  I will do that.  Thanks again for all of your help.
0
trifecta2kAuthor Commented:
agx didn't want points so I selected my own answer as the solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.