jokerbla Posted October 3, 2009 Share Posted October 3, 2009 <script type="text/javascript"> <-- <?php echo ("average = $average;"); ?> // --> document.write(average); document.write("average"); </script> I want to transfer the $average from PHP to average from javascript, but this isn't working. Neither the value of average, nor the string "average" shows up at the end. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/176399-transfering-value-from-php-to-javascript/ Share on other sites More sharing options...
jokerbla Posted October 3, 2009 Author Share Posted October 3, 2009 This doesn't work either. :-\ <script type="text/javascript"> var average=<?php echo($average) ?>; </script> Link to comment https://forums.phpfreaks.com/topic/176399-transfering-value-from-php-to-javascript/#findComment-929744 Share on other sites More sharing options...
cags Posted October 3, 2009 Share Posted October 3, 2009 <script type="text/javascript"> var average = <?php echo $average; ?>; document.write(average); </script> Works fine for me. Link to comment https://forums.phpfreaks.com/topic/176399-transfering-value-from-php-to-javascript/#findComment-929751 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.