Forum Moderators: open

Message Too Old, No Replies

Escpaing Quotes and Single Quotes

         

kazisdaman3

7:05 am on Jul 17, 2007 (gmt 0)

10+ Year Member



Thanks for taking the time to help me, I'm trying to use a function with characters, but they mess up the function because of all the special characters in it. for example:

var map_cords = +44° 35' 19.82", -123° 15' 23.07" (44.588840, -123.256409;

---------------------

How would I put this in a onClick event like?

onClick="function('test',$map_cords);"

---------------

Because I have "'s 's and ,'s it totally messes the whole thing up? any ideas, I assume I have to escape but I'm totally confused!

phranque

8:32 am on Jul 17, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



put single or double quotes around the whole string.
within the string, escape the single and double quotes with backslashes.
don't worry about the commas - they are hidden by the quotes and aren't very special.

something like this should work (adding a closing paren i assume you missed):

var map_cords = '+44° 35\' 19.82\", -123° 15\' 23.07\" (44.588840, -123.256409)';

kazisdaman3

12:38 pm on Jul 17, 2007 (gmt 0)

10+ Year Member



thank you!

much appreciated!