In this script how do I send the RESULT of the wheel to a PHP variable?
function stopRotateWheel() {
clearTimeout(spinTimeout);
var degrees = startAngle * 180 / Math.PI + 90;
var arcd = arc * 180 / Math.PI;
var index = Math.floor((360 - degrees % 360) / arcd);
ctx.save();
ctx.font = 'bold 30px sans-serif';
var text = restaraunts[index]
ctx.fillText(text, 250 - ctx.measureText(text).width / 2, 250 + 10);
ctx.restore();
}
More specific "VAR TEXT = RESTARAUNTS[index]"
Can this be sent to a $turnresult PHP variable?
There are several ways you can do that. Lets say you have:
function stopRotateWheel() {
clearTimeout(spinTimeout);
var degrees = startAngle * 180 / Math.PI + 90;
var arcd = arc * 180 / Math.PI;
var index = Math.floor((360 - degrees % 360) / arcd);
ctx.save();
ctx.font = 'bold 30px sans-serif';
var text = restaraunts[index]
ctx.fillText(text, 250 - ctx.measureText(text).width / 2, 250 + 10);
ctx.restore();
//this is an easy solution to pass in value of text to php
window.location.href = "myvar.php?text=" + text;
}
or you can do it with JQuery:
<script type="text/javascript">
var text = '<?php echo $text ?>';
</script>
To send a Javascript value to PHP you'd need to use AJAX. With jQuery, it would be like this:
var text = 'data';
$.post('myvar.php', {variable: text});
You can simply use some ajax. If you have access to jQuery,
var result = "<?php echo $someValue; ?>"; // or whatever else you'd like
$.ajax({
url: 'myscript.php',
type: 'POST',
data: "result=" + result,
success: function(success) {
alert(success);
}
});
Take a look here: Jquery Ajax