title: Passing variable from JS to PHP within the same page
body: <p>I know this has been answered many times but what i am looking for is the passing of variables within the same page. I understand that PHP is a server side script while JS is the client side thus when the page loads, it will load PHP before JS thus it is impossible to do so.</p>
  
  <p>What i am seeking is an alternative method to perform my JS task which is to take the value after the ? in the address bar (//localhost/Task/delete.php?ID=1). Else alternatively is there a way around passing the variable into PHP as the value will be used to execute a SQL query.</p>
  
  <p>Thanks</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript" &gt;
  var url = window.location.href;
  var params = url.split('?ID=');
  var fdf = (params[1])
  alert(fdf);
  
  &lt;/script&gt;
  
  &lt;?php
  $random = $_GET["fdf"];
  
  echo $random;
  ?&gt;
  </code></pre>