Jump to content

Archived

This topic is now archived and is closed to further replies.

dptr1988

How do I escape single and double quotes?

Recommended Posts

I'm making a MySQL query interface in HTML. And I have some JavaScript buttons that will insert the previous queries into the form. But some MySQL querys can contain single and double quotes. Here is the JavaScript code that I am using to insert the previous query:

[code]
onClick="document.getElementById('the_form').db_query.value='text to insert \'Single quotes work\' but \"double quotes\" do not work'; return false"
[/code]

I can use single quotes if I replace the single quote with \' But i tried that for double quotes and it doesn't work. How can I insert text that contains single quotes and double quotes into the the 'db_query' textarea?

Thanks

Share this post


Link to post
Share on other sites
I found the answer to my question. I needed to replace the double quotes with & quot;. I now know that it was a HTML question, so I apologize for posting it here in the JavaScript Help message board.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.