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>

1 thought on “Get JS varible to PHP variable with an onclick function”

  1. Вы можете вот так написать:
    You can write like this:

    <form action="result.php" method="GET">
        <input type="hidden" name="var_name" value="your value">
        <button class="CLASSx" id="IDy" onclick="Run()">CLICK</button>
    </form>
    
    Reply

Leave a Comment