I am wondering if there's a way to pass a session variable (or any variable initiated in the PHP code) as an argument in a JavaScript function. As for now the code below wouldn't work. However, I am unaware of what the issue might be.
Here's the JavaScript code
var counter = setInterval(countdown, 1000);
function countdown(var seconds) {
 seconds = seconds - 1;
 if (seconds <= 0) {
  clearInterval(counter);
  document.getElementById("countdown").innerHTML = null;
  return;
 }
 
 
 document.getElementById("countdown").innerHTML = seconds + " seconds left";
 return seconds;
}Here's the HTML code
<?php
if(isset($_POST['btn-submit']) {
   $counter = 30;
}
?>
<html>
      <body>
  <div id="container">
   <form method="post">
    <button type="submit" name="btn-submit" onclick="countdown($counter)">Confirm</button>
   </form>
   <p id="countdown"></p>
  </div>
 </body>
</html>Thanks in advance!
EDIT: One of the issues was putting 'var' in front of 'seconds' in the function
 
     
    