|
Answer» I'm trying to make it so that there is a form in which a visitor to the web PAGE can input RGB values and click submit to change the background and text colors. This is what I have so far, but when I click submit it reloads to a page with the background color but nothing else. Does anybody know what's wrong with my script? Thank you.
"http://www.w3.org/TR/html4/loose.dtd">
function rainbowfy() { var red1 = (document.changeColors.redBg.value); var green1 = (document.changeColors.greenBg.value); var blue1 = (document.changeColors.blueBg.value);
var red2 = (document.changeColors.redTxt.value); var green2 = (document.changeColors.greenTxt.value); var blue2 = (document.changeColors.blueTxt.value); document.write(""); document.write(""); }
function get_random() { var ranNum=Math.floor(Math.random()*5); return ranNum; } function getaQuote() { var whichQuote=get_random();
var quote=new Array(5) quote[0]="You may be deceived if you trust too much, but you willl live in torment if you do not trust enough. -Frank Crane"; quote[1]="I am extraordinarily patient, provided I get my own way in the end. -Margaret Thatcher"; quote[2]="The deepest DEFINITION of YOUTH is life as yet untouched by tragedy. -Alfed North Whitehead"; quote[3]="Always remember others may hate you but those who hate you don't win unless you hate them. And then you destroy yourself. -Richard M. Nixon"; quote[4]="Always FORGIVE your enemies. Nothing annoys them so much. -Oscar Wilde";
document.write(quote[whichQuote]); }
Select Colors
Background (enter values from '00' to FF')
RED: GREEN: BLUE:
Text (enter values from '00' to 'FF')
RED: GREEN: BLUE:
getaQuote();
When changing the background color, use the Javascript syntax and not the "document.write()" function.
Use this
Code: [Select]document.style.body.backgroundColor="#000000"; //Just make it so that the value above is what the user wants //You could try a variable set to the right color
|