desjardins2010 Posted December 21, 2010 Share Posted December 21, 2010 the script here is the simplest progress bar ever.. what I want is for the value of the mutiplier (so how fast it loads) to be a php varible pulled from the users file <html> <head> <script type="text/javascript"> function progress() { if (document.images["bar"].width < 400) { document.images["bar"].width += 5; document.images["bar"].height = 5; } else { clearInterval(ID); } } var ID; window.onload = function() { ID = setInterval("progress();", 500); } </script> </head> <body> <img src="black.gif" name="bar" /> </body> </html> POSSIBLE? Link to comment https://forums.phpfreaks.com/topic/222343-can-i-mix-php-into-a-javascript/ Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 sorry just noticed the php wasn't in here anyone the 500 online ID = setInterval("progress();", 500); is the multiplier I would like to be something like ("progress();",<?php $num ?>); Link to comment https://forums.phpfreaks.com/topic/222343-can-i-mix-php-into-a-javascript/#findComment-1150099 Share on other sites More sharing options...
BlueSkyIS Posted December 21, 2010 Share Posted December 21, 2010 yes. imagine javascript as just some different HTML that PHP can put values into. Link to comment https://forums.phpfreaks.com/topic/222343-can-i-mix-php-into-a-javascript/#findComment-1150100 Share on other sites More sharing options...
desjardins2010 Posted December 22, 2010 Author Share Posted December 22, 2010 whats the format then cause the above I tried and didn't work Link to comment https://forums.phpfreaks.com/topic/222343-can-i-mix-php-into-a-javascript/#findComment-1150112 Share on other sites More sharing options...
Marcel1993 Posted December 22, 2010 Share Posted December 22, 2010 Hey, there is no different between including PHP in HTML or JavaScript. I recommend to use this Format <?php echo $var; ?> With the version above you won't get trouble. In some cases you will get trouble with " or ' if you use mixed code. echo "<javasc..." Link to comment https://forums.phpfreaks.com/topic/222343-can-i-mix-php-into-a-javascript/#findComment-1150131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.