0

I have this code

<?php $test = 16010; ?>
<button "onclick="myFunction('<?php echo $test; ?>')" data-toggle="modal" data-target="#myModal">Edit</button>
<script>
function myFunction(number) {  document.getElementById("result").innerHTML = number;</script>

<p id='result'></p>

This code will show the result: 16010, but I don't know how to put that value in a php var. Please help!

Aadv
  • 21
  • 1
  • 3
  • PHP is a server side language which is executed and then the HTML is sent to the browser. The browser then executes JavaScript within the context of the HTML document. So, you need to send the data back to the server with e.g. a POST request to have it there (and it will execute a new PHP file, not the one which sent the data to the browser). – ssc-hrep3 Jun 29 '21 at 19:13

0 Answers0