Get JS varible to PHP variable with an onclick function

I want to have a button that run my js function onclick and take the variable data and send it to result.php file. How can i do that

My code simplified:

function Run() {
  var Variable0 = document.getElementById("ElementX");
}
<form action="result.php" method="GET">
  <button class="CLASSx" id="IDy" onclick="Run()">CLICK</button>
</form>

6 thoughts on “Get JS varible to PHP variable with an onclick function”

Leave a Comment