Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.