Level 104
PHP has already been executed and "returned" by the time your Javascript can get to work; you would need a new Request to pass a value into PHP.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So i have a button that when clicked it displays the id like below
<?php
$id = 2;
?>
<buttton onclick="getId($id)">click me</button>
<script>
function getId(id){
console.log(id) //displays 2
}
</script>
how do i pass the getId value to another php variable??
Please or to participate in this conversation.