...

View Full Version : Help



Aker15
03-01-2012, 07:25 PM
I have completely no idea why this is not working...



<script type="text/javascript">
var BGS = new Array();

BGS[0] = '#00FF00'; /// YELLOW ///
BGS[1] = '#FF0000'; /// RED ///
function changebgr(choice)
{
document.bgColor = BGS[choice];
}

function reloadpage()
{
window.location.reload();
}
document.write(Date());
</script>


Idea's?
The changebgr function is not working when i do this:



<center><input type="button" value="Red Background" onclick="changebgr(1)"></center>
<center><input type="button" value="Yellow Background" onclick="changebgr(0)"></center>

Philip M
03-01-2012, 07:32 PM
Well, it works for me except that #00FF00 is green, not yellow. The (rather pointless) function reloadpage() is not called anywhere.

Be aware that document.write() statements must be run (as you are doing here) before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.

Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.


It is your responsibility to die() if necessary….. - PHP Manual

Aker15
03-01-2012, 07:36 PM
Hmm.. I know reloadpage() is not called anywhere, this is because i did not show you the code I used it for... I will read it no need to be a dickhead.

Thanks

Philip M
03-01-2012, 07:40 PM
Hmm.. I know reloadpage() is not called anywhere, this is because i did not show you the code I used it for... I will read it no need to be a dickhead.



So how much help do you expect to get in this forum in future?



var rude = true;
var thanks = false;
if (rude && !thanks) {
var interestLost = true;
var moreHelp = 0;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum