Rendering javascript code in php document
<p>I'm a beginner to PHP and I have a quick question. Is it possible to have javscript code injected into a document through php?</p>

<p>For example, suppose I wanted to inject a button that called a function after a form is filled out:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
  &lt;script type = text/javascript&gt;
  function func() {
  ...
  }
  &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form action = 'welcome.php' method = 'post&gt;
Name: &lt;input type = 'text' name = 'fname' /&gt;
&lt;input type = 'submit' value = 'submit' /&gt;
&lt;/form&gt;

&lt;?php
if (isset($_POST['fname'])) {
   echo '&lt;input type = button onclick = func /&gt;'
}
?&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Would this work? If not, why not?</p>

<p>Any help would be great</p>
