I have read through just about every question on here trying to get a numeric value passed from PHP to javascript. As you can see I generated random numbers successfully and it worked great, but when I tried to pass the variables to the graph.update function, even though both variables do have values according to firebug (14060116, and 0 respectively, which is right) they aren't making it to the update function... any ideas? Here's the full script if it helps!
<script>
(function () {
function createCanvas(divName) {
var div = document.getElementById(divName);
var canvas = document.createElement('canvas');
div.appendChild(canvas);
if (typeof G_vmlCanvasManager != 'undefined') {
canvas = G_vmlCanvasManager.initElement(canvas);
}
var ctx = canvas.getContext("2d");
return ctx;
}
var ctx = createCanvas("graphDiv1");
var upld = <?php echo json_encode($dirupld[0]); ?>;
var upldred = <?php echo json_encode($dirupldred[0]); ?>;
var graph = new BarGraph(ctx);
graph.maxValue = 30;
graph.margin = 10;
graph.width = 450;
graph.height = 200;
graph.colors = ["#49a0d8", "#d353a0"];
graph.xAxisLabelArr = ["Traditional", "Duplicate Reduced"];
graph.update([upld, upldred]);
//graph.update([Math.random() * 30, Math.random() * 30]);
}());
</script>
Not sure where I am losing the values? Firebug is reporting the following
var upld = 14060116;
var upldred = 0;
graph.update([upld, upldred]);