Quotes problem when passing value to Javascript
<p>I am using like</p>

<pre><code>$myPage .= '&lt;td&gt;&lt;a href=\'javascript:editProduct('
    .$row['id']
    .',"'
    .$row['name']
    .'")\'&gt;Edit&lt;/a&gt;&lt;/td&gt;';
</code></pre>

<p>where <code>$row['name']</code> has quotes in its value. it breaks. how do i solve the issue both from php side and js side...</p>

<p><code>$row['name']</code> is value from DB. and it will have value like <code>pradeep's</code> and <code>pradeep"s</code> also</p>

<p>i used like</p>

<pre><code>$myPage .= '&lt;td&gt;&lt;a href=\'javascript:editProduct('.addslashes($row['id']).',"'.addslashes($row['name']).'")\'&gt;Edit&lt;/a&gt;&lt;/td&gt;';
</code></pre>

<p>it solves the issue of double quotes. but when i have single quotes in value the javascrit link looks like</p>

<pre><code>javascript:editProduct(28,"pradeep\
</code></pre>

<p>it actually breaks..</p>

<p>And how do i strip down the slashes added by addslashes in javascript..</p>

<p>UPDATE - FINAL CODE</p>

<pre><code>$myPage .= '&lt;td&gt;&lt;a href=\'javascript:editProduct('.$row['id'].',"'.htmlentities($row['name'],ENT_QUOTES).'")\'&gt;Edit&lt;/a&gt;&lt;/td&gt;';
</code></pre>

<p>and js looks like </p>

<pre><code>function editProduct(id,name){
        alert(name);
        }
</code></pre>

<p>can any one solve my issues</p>
