Jump to content

can I mix php into a javascript


desjardins2010

Recommended Posts

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

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..."

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.