alx
06-06-2003, 02:42 PM
I'm trying to get my background to change randomly when someone presses a button but It's not working. Can you help? :chicken:
|
View Full Version : random background problem alx 06-06-2003, 02:42 PM I'm trying to get my background to change randomly when someone presses a button but It's not working. Can you help? :chicken: Lemon Squash 06-06-2003, 03:13 PM Umm not with no code.. Can you post your code? Or url? alx 06-06-2003, 03:18 PM umm... sorry. Here it is: <HTML> <HEAD> <TITLE>background colour changer</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin Javascript function Random(maxVal) { Day=new Date(); hour=day.getHours(); min=day.getMinutes(); sec=day.getSeconds(); return (((hour+1)*(min+1)*sec)%maxVal)+1; } function MakeArray(size) { this.length=size; for(var i=1; i<=size; i++) {this[i]=0} return this; } function SetBkgndColor() { colorArray=new MakeArray(7) colorArray[1]="#FF0000"; colorArray[2]="#00FF00"; colorArray[3]="#FFFF00"; colorArray[4]="#0000FF"; colorArray[5]="#FF00FF"; colorArray[6]="#00FFFF"; colorArray[7]="#FFFFFF"; document.bgcolor=colorArray[Random(7)]; } //--> </SCRIPT> </HEAD> <BODY> <HR> <FORM> Click here and I'll change color! <INPUT TYPE="button" Value="Change My Color!" ONCLICK="SetBkgndColor()"> </FORM> <HR> </BODY> </HTML> sherri 06-06-2003, 06:23 PM I am not good at looking at a code and just pointing out what is wrong with it. But you can go here for other background choosers: http://javascript.internet.com/bgeffects/random-background.html http://javascript.internet.com/bgeffects/r-colors.html http://javascript.internet.com/bgeffects/background-color-change.html http://javascript.internet.com/bgeffects/background-color-changer.html Hope this helps you alittle bit. :) alx 06-06-2003, 08:20 PM Thanks. you've helped. sherri 06-06-2003, 11:35 PM Glad I could help! :) |