pass php variable value to javascript

javascript, php

Solution

$distance is an integer? why don't you just write

var dist = <?php echo $distance; ?>

Problem

Im trying to pass the value of a php variable into javascript but i just cant get it to work. Am I doing anything wrong? Below is the line of code I'm working with. ``` var dist = parseInt("<?php echo json_encode($distance); ?>"); ```

Original source

Related problems