issue calling JavaScript function from PHP
<p>basically I am trying to call a javascript function from my PHP and I am using code I know works in other situations however here is it not and I am at a loss as to why? </p>

<p>It may be something stupid as I have been staring at this screen for a long time :)</p>

<p>here is where I call the function:</p>

<pre><code>if(isset($test_details['done_test'])){
    echo "getting here";
    echo "&lt;SCRIPT LANGUAGE='javascript'&gt;user_error();&lt;/SCRIPT&gt;";
}
</code></pre>

<p>I successfully get 'getting here' printed however it does not call the JS function.</p>

<p>javascript function:</p>

<pre><code>   function user_error(){
   document.write("working");
        //alert("User has already taken this test. Your are being redirected...");
        //setTimeout("window.location='home_student.php'",3000);
   }
</code></pre>

<p>The commented it what I do eventually want it to do.</p>

<p>Could anyone please shed some light.</p>

<p>Many thanks,</p>

<p>@Crimson - Here is what I tried after your advice...still no luck.</p>

<p>javascript now:</p>

<pre><code>$(document).ready(function () {
     var done = "&lt;?= $test_details['done_test'] ?&gt;";
     if(typeof done != 'undefined'){
          $('WORKING').appendTo('#bodyArea'); // just to test
     }
});
</code></pre>
