title: How to get the result of a js function called with <script>?
body: <p>I am currently working on a quizz page with code people have already done before. I have to add a timer and when the timer is done, I have to send a form.
  I have decided to make my function a boolean to get the result directly with the return. When it's true, then the timer is over. But the problem is 
  I call a js function in the html and I don't know how to get the return result.</p>
  
  <p>This is the part of the code I need help on :</p>
  
  <pre><code>echo '&lt;body&gt;
    &lt;div class="body"&gt;';
         if($type=='t'){
               $timer = false;
               echo '&lt;div id="clockdiv"&gt;&lt;/div&gt;';
               echo '&lt;script language="javascript"&gt;timer = setInterval(timer(), 10000)&lt;/script&gt;';
               echo $timer;
           }
  </code></pre>
  
  <p>And my js function :</p>
  
  <pre><code>function timer(){
            var running = false;
            var time_in_minutes = 0.3;
            var current_time = Date.parse(new Date());
            var deadline = new Date(current_time + time_in_minutes*60*1000);
            function run_clock(id,endtime){
              var clock = document.getElementById(id);
              function update_clock(){
                            function time_remaining(endtime){
                               var t = Date.parse(endtime) - Date.parse(new Date());
                               var seconds = Math.floor( (t/1000) % 60 );
                               var minutes = Math.floor( (t/1000/60) % 60 );
                               var hours = Math.floor( (t/(1000*60*60)) % 24 );
                               var days = Math.floor( t/(1000*60*60*24) );
                               return {'total':t, 'days':days, 'hours':hours, 'minutes':minutes, 'seconds':seconds};
                            }
          var t = time_remaining(endtime);
          clock.innerHTML = 'minutes: '+t.minutes+'&lt;br&gt;seconds: '+t.seconds;
          if(t.total&lt;=0){ 
                    clearInterval(timeinterval);
                    clock.innerHTML = 'Temps écoulé';
                    running = true;
                   }
      }
      update_clock(); // run function once at first to avoid delay
      var timeinterval = setInterval(update_clock,1000);
  }
            run_clock('clockdiv',deadline);
            return running;
  }
  </code></pre>