Jump to content

Calling php var in javascript?


Gutspiller

Recommended Posts

Here is my current code.

 

<?php 
echo "
<script type=\"text/javascript\">
<!--
var containerID = \"advertise\";
var number = 16;
var timerID = setInterval(\"CountdownTimer()\",1000);
function CountdownTimer() {
if(number > 1) {
number--;
ReplaceContentInContainer(containerID,number);
}
else {
clearInterval(timerID);
ReplaceContentInContainer(containerID,'<p class=\"downbutton\"><a href=\"download.php?shortURL=$filedrop->shortURL\" class=\"uploadbutton round-tl-br-xl green-matte\">Download</a></p>');
}
}
//-->
</script>
"; ?>

 

This works in the page I have it on, but I am trying to instead of showing all that in the source, have it show something like

 

<script type="text/javascript" src="dbutton.js"></script>

 

The problem is that the php variable $filedrop->shortURL isn't being processed when I move it all over to its own js file. It writes out "$filedrop->shortURL"  instead.

 

I don't know much at all about javascript, other than looking at code and stumbling my way through it. Can somebody rewrite this code as to how I should insert it into my dbutton.js file to make it still work with that php variable?

 

Thanks in advanced for any help you can offer me.

Link to comment
https://forums.phpfreaks.com/topic/247632-calling-php-var-in-javascript/
Share on other sites

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.