Reputation: 653
I have PHP Script / HTML
$string1 = 'Foo';
$string2 = 'Bar';
$string3 = 'This string contains some URL';
$string4 = 'This string contains multi-line short description which contains single quotes, double quotes and some comma characters as well.';
Here is my onClick
<a class="someClass" title="someTitle" href="#" onclick="someFunction('<?php echo $string1; ?>', '<?php echo $string2; ?>', '<?php echo $string3; ?>', '<?php echo $string4; ?>')">Click Here</a>
But while receiving, I am getting all sorts of string parsing errors on someFunction()
Upvotes: 0
Views: 65
Reputation: 2238
In php side use:
<?php echo addslashes($string1); ?>
And inside someFunction( string1 ) use:
string1 = string1.replace(/\\/g, '');
To get the normal value of the string;
Upvotes: 1