Problem calling a js function from php
<p>I am using my php to call a js function like this:</p>

<pre><code>&lt;?php 
$chk=1;
if($chk==1)
{
    echo '&lt;script&gt;testing();&lt;/script&gt;';
}
?&gt;
</code></pre>

<p>and my js looks like:</p>

<pre><code>function testing()
{
   document.getElementById("mainbody").innerHTML="This is my first JavaScript!";
}
</code></pre>

<p>The js is an external js file.</p>

<p>My html looks like:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script src="qotw.js"&gt;&lt;/script&gt;
&lt;/head&gt; 
    &lt;body&gt;
    &lt;div id="mainbody"&gt;&lt;/div&gt;     
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>but this is not working. What am i doing wrong over here?
Please tell me if you know. </p>

<p>Best
Zeeshan</p>
