dimanche 4 janvier 2015

PHP variable to JavaScript variable to HTML span

I'm trying to get a random question in 1 file (a PHP file), and getting that question in another file (a HTML file) that doesn't support PHP. Do you have any idea why/what isn't working?


This is what I already tried:



<?php
$q = "How much is 5 plus 4?";
?>

<script>
var qu = <?php echo $q; ?>;
document.getElementById("quest").innerHTML = this.qu;
</script>

<span id="quest"></span>


Thank you.


Aucun commentaire:

Enregistrer un commentaire