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.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
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("<body bgcolor='#" + red1 + green1 + blue1 + "'>");
document.write("<font color='#" + red2 + green2 + blue2 + "'>");
}
</script>
<script type="text/javascript">
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]);
}
</script>
</head>
<body>
<h2>Select Colors</h2>
<form name="changeColors">
Background (enter values from '00' to FF')
RED:<input name="redBg" type="text" style="width: 30px;">
GREEN:<input name="greenBg" type="text" style="width: 30px;">
BLUE:<input name="blueBg" type="text" style="width: 30px;">
Text (enter values from '00' to 'FF')
RED:<input name="redTxt" type="text" style="width: 30px;">
GREEN:<input name="greenTxt" type="text" style="width: 30px;">
BLUE:<input name="blueTxt" type="text" style="width: 30px;">
<input name="apply" type="button" value="Submit" onclick="rainbowfy();" />
</form>
<script type="text/javascript">
getaQuote();
</script>
</body>
</html>