Use HTML variable inside JavaScript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/168214/pass-a-php-string-to-a-javascript-variable-including-escaping-newlines">Pass a PHP string to a Javascript variable (including escaping newlines)</a>  </p>
</blockquote>



<p>Let's say there is some PHP file called as <code>scheduler.php</code>. It contains a script</p>

<pre><code>&lt;script&gt;
window.setInterval(function(){
    find_opt_schedule();
}, 60000);
&lt;/script&gt;
</code></pre>

<p>... and some PHP code:</p>

<pre><code>&lt;form action="scheduler.php" method="post"&gt;
    &lt;select name="refresh" id="refresh"&gt;
            &lt;option value="30000"&gt;30000&lt;/option&gt;
            &lt;option value="60000" selected&gt;60000&lt;/option&gt;
            &lt;option value="120000"&gt;120000&lt;/option&gt;
    &lt;/select&gt;
&lt;/form&gt;
</code></pre>

<p>How do I use the value selected by the user from <code>refresh</code> select list inside the script? In particular, I want to replace 60000 by the variable that must be selected by the user from the list. I tried this, but the refresh rate is very high instead of 60000 miliseconds.</p>

<pre><code>window.setInterval(function(){
    find_opt_schedule();
    alert(&lt;?php echo (int)$_POST['refresh']; ?&gt;);
}, &lt;?php echo (int)$_POST['refresh']; ?&gt;);
</code></pre>
