I am trying to pass the value of a javascript variable to a php variable.
This is my code but it’s not passing anything…
<script>
var newVar = "2000";
<?php $value ?> = newVar;
</script>
Sorry, I need to javascript variable to be passing into php.
Code above turned round.
This is how you pass from PHP to your Javascript. Your newVar will take the values of $value.
However reading again “of a javascript variable to a php variable” i see that you would like to pass a variable from javascript to php which you have several methods to do: in a form via GET or POST, in a link via GET, or via ajax.