How To Pass a PHP Variable To Javascript
<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;?php
$your_name=$_POST['name'];
?&gt;
&lt;script language="javascript"&gt;
function fash(at1,at2)
{
    alert(at1+at2);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php
echo $your_name;
echo '&lt;script language="javascript"&gt;fash("the key is: "+'&lt;?php echo $your_name; ?&gt;');&lt;/script&gt;';
?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The output is:</p>

<blockquote>
  <p>the key is : undefined</p>
</blockquote>

<p>How can I fix this?</p>
