title: How to echo javascript code in php
body: <p>I am having a problem with how to echo javascript in php. I have a form which on submit will execute itself and echo some text and will redirect to a page in 5secs. I am currently echoing this:</p>
  
  <pre><code>header("Refresh: 5;url=index2.php?ID=".$objResult["ID"]."");
  
  echo '&lt;html&gt;';
  echo '&lt;head&gt;';
  echo '&lt;title&gt;Klant toevoegen&lt;/title&gt;';
  echo '&lt;link rel="stylesheet" href="style.css" type="text/css" media="screen" /&gt;';
  echo '&lt;/head&gt;';
  echo '&lt;body&gt;';
  echo '&lt;fieldset&gt;';
  echo ''.$Naam.' is added to the database, u will be redirected in a couple of seconds.&lt;br&gt;&lt;br&gt;';
  echo '&lt;/fieldset&gt;';
  echo '&lt;/body&gt;';
  echo '&lt;/html&gt;';
  </code></pre>
  
  <p>The javascript I have is a countdown which counts down from 5 to 1. The code is this:</p>
  
  <pre><code>&lt;script&gt;
  
  var countdownFrom = 5;  // number of seconds
  var countdownwin;
  
  var stp;
  function CountDownStart() {
   stp = setInterval("CountDownTimer('CountDownTime')",1000)
  }
  
  function CountDownTimer(id)
  {
  if (countdownFrom==0) {clearInterval(stp); window.close(); }
  else     {
              var x
              var cntText = "Closing in "+countdownFrom+" seconds";
  
          if (document.getElementById)
      {
          x = document.getElementById(id);
          x.innerHTML = cntText;        }
      else if (document.all)
      {
          x = document.all[id];
          x.innerHTML = cntText;        }
      }
  countdownFrom--
  }
  
  &lt;/script&gt;
     &lt;title&gt;Untitled&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body onload="CountDownStart()"&gt;
  
  &lt;Div id="CountDownTime"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>Now I would like to echo this countdown script to replace the <code>&lt;fieldset&gt;</code> in the html. I have tried several things like just add the whole code in 1 <code>echo '';</code> and I tried to echo all the lines seperately but with both it crashes my whole script. If anyone knows how to do this it would be great!</p>