Jump to content


Photo

How do I escape single and double quotes?


  • Please log in to reply
1 reply to this topic

#1 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 22 June 2006 - 04:38 PM

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:

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

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
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )

#2 dptr1988

dptr1988
  • Members
  • PipPipPip
  • Advanced Member
  • 372 posts

Posted 22 June 2006 - 11:45 PM

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.
Need more help with your project? One of the thousands of programmers, web designers or artists at <a href="http://www.rentacode...d_6764522">Rent A Coder</a> would be happy to help.

Disclaimer: Free advice is usually worth what you paid for it. ( or at least when it's coming from me! )




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users