Hey Guys,
I’m trying to use Javascript to display two possible sets of content. One set of content is served to an affiliate, whose traffic has “?hop=fuzzphil” in the URL. I’m using PHP to grab the parameter, then passing it into JavaScript and trying to use an in-else statement to determine which hidden div to display. Beneath the JS code are two hidden divs with different names; I want to use JS to trigger the display of either section after a time delay.
Here’s what my code looks like right now:
[CODE]<?php $affiliateid = $_REQUEST[‘hop’]; ?>
<script type=”text/javascript”>
var hopid=”<?php echo $affiliateid; ?>”;
if (hopid == “fuzzphil”) {
function showBuyLink() {
document.getElementById(“buttonphilippe”).style.display = “inline”;
setTimeout(“showBuyLink()”, 5000);
}
}
else {
function showBuyLink() {
document.getElementById(“buylink”).style.display = “inline”;
setTimeout(“showBuyLink()”, 1000);
}
}
</script>
Beneath the code are two divs with “display: none” and the id set to either “buylink” or “buttonphilippe.” I’ve tested the delay code independently and it works, but something in the if-else is breaking it I think. I’ve also tested just putting the PHP hop ID into the variable and it document.writes just fine, so I’m not sure what’s going on.
Thanks for the help ?