How to separate PHP code and Javascript code
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1316203/how-can-i-separate-javascript-from-php-when-the-js-needs-a-php-variable">How can I separate javascript from PHP when the JS needs a PHP variable?</a><br>
  <a href="http://stackoverflow.com/questions/13734338/how-to-define-a-variable-in-javascript-with-php-echo-function">How to define a variable in JavaScript with PHP echo function?</a>  </p>
</blockquote>



<p>For example I have the following Javascript code. It uses PHP variables.</p>

<pre><code>&lt;script&gt;
 $(function() {
     for(var items = 1; items &lt;=&lt;?php echo $items;?&gt;; items++){
         print_percentage_is("div.is"+items);
     }
});
&lt;/script&gt;
</code></pre>

<p>What's the best solution to separate the Javascript code with my Html/PHP code? For this case I can not use this way</p>

<pre><code>&lt;script type="text/javascript" language="javascript" src="/js/change.js"&gt;&lt;/script&gt;
</code></pre>

<p>Do I need to create a PHP file and put the javascript in? What's the best solution?</p>
