ge00rge Posted December 12, 2006 Share Posted December 12, 2006 Hi all,I'm using a file hosting script and when someone goes to the download page to download a filethere's a countdown timer.So when then counter goes to zero,the following code is usedto display a button and give access to the file:[code]<?php if($downloadtimer == 0) {echo "<input type=submit value=\"Download it\" onClick=\"".$scripturl. "download2.php?a=" . $filecrc . "&b=" . md5($foundfile[2].$_SERVER['REMOTE_ADDR'])."\">"; } else { ?>If you're seeing this message, you need to enable JavaScript<?php } ?> [/code]I have already tried [code]style=\"position:relative;top:$top;left:$left;\" [/code] + [code]$top = rand(0,100);$left = rand(0,100); [/code] but it's not working.So is there any way to change the position of the "download button" using php?thanks!ps.I can post the whole script code if it's necessary. Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/ Share on other sites More sharing options...
marcus Posted December 12, 2006 Share Posted December 12, 2006 [code]<?php$top = rand(1,100);$left = rand(1,100);echo "<div style=position:absolute; top:$top; left:$left;>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139952 Share on other sites More sharing options...
ge00rge Posted December 12, 2006 Author Share Posted December 12, 2006 mgallforever could you be a bit more specific?The code I posted is already inside a <div>,so where exactly should I place your code?thanks! Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139954 Share on other sites More sharing options...
mlacy03 Posted December 12, 2006 Share Posted December 12, 2006 You could also use the following:[code]<style>.test{position:absolute;left:<?php echo rand(0,100); ?>px;top:<?php echo rand(0,100); ?>px;}//put this with your earlier styles, and make sure that you haven't used the word test to define any classes</style>...<?php echo "<div class=\"test\"><input type=submit value=\"Download it\" onClick=\"".$scripturl. "download2.php?a=" . $filecrc . "&b=" . md5($foundfile[2].$_SERVER['REMOTE_ADDR'])."\"></div>";?>[/code]Just the way you had it in your PHP tag, plus the required <div> Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139959 Share on other sites More sharing options...
marcus Posted December 12, 2006 Share Posted December 12, 2006 just put it in your body tags Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139964 Share on other sites More sharing options...
ge00rge Posted December 12, 2006 Author Share Posted December 12, 2006 Ok,I changed the code to this:[code]<?php $top = rand(1,300);$left = rand(5,100);if($downloadtimer == 0) {echo "<div style=position:absolute; top:$top; left:$left;><input type=submit value=\"Download It\" onClick=\"".$scripturl. "download2.php?a=" . $filecrc . "&b=" . md5($foundfile[2].$_SERVER['REMOTE_ADDR'])."\"></div>"; } else { ?>If you're seeing this message, you need to enable JavaScript<?php } ?>[/code]I'm not getting any errors,but when the counter goes to zero the button stays on the same place.Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139966 Share on other sites More sharing options...
marcus Posted December 12, 2006 Share Posted December 12, 2006 what does $downloadtimer equal? Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139968 Share on other sites More sharing options...
ge00rge Posted December 12, 2006 Author Share Posted December 12, 2006 I did some testsSummary:After your help I changed the code to this:[code]<?php$top = rand(1,100);$left = rand(1,100);echo "<div style=position:absolute; top:$top; left:$left;>";?><?php if($downloadtimer == 0) {echo "<input type=submit value=\"Download It\" onClick=\"".$scripturl. "download2.php?a=" . $filecrc . "&b=" . md5($foundfile[2].$_SERVER['REMOTE_ADDR'])."\">"; } else { ?>If you're seeing this message, you need to enable JavaScript<?php } ?></div>[/code]And now instead of the counter I get this message: "If you're seeing this message, you need to enable JavaScript".mgallforever: $downloadtimer is defined in a config file.I have set it to 5 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-139974 Share on other sites More sharing options...
ge00rge Posted December 13, 2006 Author Share Posted December 13, 2006 I'm trying to post some javascript which is included in the script we are talking about but I keep getting server timeouts...EDIT:I just noticed that the thread was moved,sorry. Quote Link to comment https://forums.phpfreaks.com/topic/30411-how-to-change-position-on-each-page-load/#findComment-140018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.