update JS Var on chaging of a php var
<p>I got this prob. In a web page I have a DIV that display a counter ( a PHP variable, $count). I have also a JS function that change the INNERHTML property of the DIV. I'm not able to change the js var on the changing of the PHP one.</p>

<p>HTML</p>

<pre><code>&lt;DIV id="counter"&gt;0&lt;/DIV&gt;
</code></pre>

<p>PHP</p>

<pre><code>while (----) {
  do_something;
  $count++;
}
</code></pre>

<p>JS</p>

<pre><code>function ChangeDiv() {
document.getElementById("counter").innerHTML = // here the value of $count;
}
setinterval("ChangeDiv()",3600);
</code></pre>

<p>I want to to refresh the DIV every sec inserting in it the value of $count... but doing</p>

<pre><code>document.getElementById("counter").innerHTML = &lt;?php echo($count); ?&gt;;
</code></pre>

<p>is wrong 'cause it will output just the initial value of $count.</p>

<p>I tried to insert a parameter in the function ChangeDiv, but in that way I had to call the function every time $count changed, echoing a </p>

<pre><code>echo("&lt;script&gt;ChangeDiv('".$count."');&lt;/script&gt;");
</code></pre>

<p>...that's really not functional.</p>

<p>Someone knows a simpler way to do it??</p>
