title: How to call javascript function/write script inside PHP echo
body: <p>I have written piece of code, below is the code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function submitform()
  {
      document.myform.action='http://mysite/index.php';
      document.myform.submit();
  }
  &lt;/script&gt;
  
  &lt;?php
  if(isset($_POST['submit_details']))
  {
         echo "&lt;script typ=javascript&gt; submitform();&lt;/script&gt;";
  }
  
  ?&gt;
  &lt;form id="myform"&gt;
    ------
    ------
  &lt;input type="submit" name="submit_details"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>when i try to submit the form , it gives me error document.myform is undefined, how to solve this error</p>