In the following example of code I want to store the JavaScript variable val
into a PHP variable $ff
.
<script>
$(document).ready(function() {
$("#type").change(function() {
var val = $(this).val();
alert(val);
<?php $ff = "Greenway"; ?>
});
});
</script>
The var val
stores the name of shops, e.g. "GreenWay", "Tropin". I want to store this data in a PHP variable. I tried doing <?php $ff = $_GET['val']; ?>
but it doesn't work.