vonKristoff Posted October 5, 2011 Share Posted October 5, 2011 Hiya .. I just want to feed in a variable to my javascript on my HTML page, via PHP because it is grabbing data from the server ... I have a php function that gets called in my header that does something like this: echo 'flashvars.myvar = "'.$src.'";'; basically I am passing a var to swfObject like so: (see the php call) <script type="text/javascript"> var params = {}; params.menu = "false"; params.scale = "noscale" params.wmode = "transparent"; params.allowfullscreen = "true"; var flashvars = {}; <?php getHTMLVar(); ?> swfobject.embedSWF("flash/video.swf", "index", "100%", "100%", "9.0.0","expressInstall.swf",flashvars,params); </script> to all u freaks - u already know that this doesnt work, and the page breaks - why is this - and is there another solution? Thanks! Link to comment https://forums.phpfreaks.com/topic/248481-php-to-javascript-var/ Share on other sites More sharing options...
AyKay47 Posted October 5, 2011 Share Posted October 5, 2011 the way that I pass PHP variables to javascript is via a javascript function somefunc("<?php echo $some_var; ?>") Link to comment https://forums.phpfreaks.com/topic/248481-php-to-javascript-var/#findComment-1276026 Share on other sites More sharing options...
vonKristoff Posted October 5, 2011 Author Share Posted October 5, 2011 cool thanks. Also I just worked out like this.. flashvars.myvar = "<?= $src ?>"; &by declaring the function up top which creates the variable instance. Link to comment https://forums.phpfreaks.com/topic/248481-php-to-javascript-var/#findComment-1276028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.