Reputation: 26107
How can I embed the following parameter string in an onclick event without breaking the JS? Right now there is collision with double Quotes. the values in th onclick event are coming from a JS variable.
Ex:
initializeMap('["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933","2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"]','%68%74%74%70%3a%2f%2f');
In an Onclick Event:
<a href="#-" onclick="JavaScript:initializeMap('["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933","2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"]','%68%74%74%70%3a%2f%2f');">Click Me</a>
Thanks
Upvotes: 0
Views: 1468
Reputation: 92274
Like Jake said, this is better to handle without inline handlers. Nobody nowadays should be using inline handlers. Having said that, there are two options:
"["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933","2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"]"
Upvotes: 2
Reputation: 3411
I would go for a JS handler for the onclick event.
If you are stuck with inline JS, try using
<a href="#-" onclick='initializeMap(["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933",
"2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"],"%68%74%74%70%3a%2f%2f");'>Click Me</a>
Upvotes: 1