title: php javascript echo javascript variable to php loop condition dynamically using onclick or how can I use ajax to solve it?
body: <p>How can I store only the value of f() into <code>$ab</code>?
  How can I also change $ab dynamically in the loop condition when the button is pressed so that the integers are printed out dynamically?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var i = 0;
  function f(){
  i = i + 10;
  document.getElementById("more").innerHTML= i;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>php</p>
  
  <pre><code>$ab = "&lt;p id='more'&gt; &lt;/p&gt;";
  echo $ab;
  for($x=0;$x&lt;$ab;$x++) echo $x . "&lt;br&gt;";
  echo "&lt;button type='button' onclick='f()'&gt; &gt; &lt;/button&gt;";
  </code></pre>