I’m am trying to get this script to work. I want to change background colors of the cell. But really I’m a noob to javascript and I don’t understand what I’m doing wrong. please just give me some hints towards making it right, So I can learn better.
code:
[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<meta content=”text/html; charset=ISO-8859-1″ http-equiv=”content-type”>
<title>Javascript can be so confusing</title>
<style type=”text/css”>
.text
{
font: 10pt arial;
color: black;
}
</style>
<script type=”text/javascript”>
function changeBG(id, whichColor) {
var backColor = [‘BLACK’, ‘WHITE’, ‘SILVER’, ‘PINK’, ‘RED’, ‘GOLD’, ‘GREEN’, ‘PURPLE’, ‘BLUE’, ‘NAVY’, ‘ORANGE’, ‘TURQUOISE’];
var aryColor= new array(12);
aryColor[0] = “BLACK”;
aryColor[1] = “WHITE”;
aryColor[2] = “SILVER”;
aryColor[3] = “PINK”;
aryColor[4] = “RED”;
aryColor[5] = “GOLD”;
aryColor[6] = “GREEN”;
aryColor[7]= “PURPLE”;
aryColor[8] = “BLUE”;
aryColor[9] = “NAVY”;
aryColor[10] = “ORANGE”;
aryColor[11] = “TURQUOISE”;
for (i=0; i < aryColor.length; i++) {
var preload = new backColor[];
preload.src = aryColor[i];
}
document.getElementById(id).style.backgroundColor = backColor.aryColor[whichColor];
return false;
}
</script>
</head>
<body>
<table cellpadding=”0″ cellspacing=”0″ align=”center” valign=”center” style=”width:500px; background-color:#F5F4E0; margin:0 auto; padding-bottom:20px;”>
<tr>
<td>
<table border=0 cellpadding=”0″ cellspacing=”3″ align=”center” valign=”center”>
<tr>
<td valign=”top” style=”text-align:center;”>
<p><span class=”text”><b>Will change the background color of the cell below!</b></span><br><br>
<form>
<select name=’Border’ class=’select’ onchange=”return changeBG(‘focus’,’arycolor’);”>
<option value=’BLACK’>Black </option>
<option value=’WHITE’>White </option>
<option value=’SILVER’>Silver </option>
<option value=’PINK’>Pink </option>
<option value=’RED’>Red </option>
<option value=’GOLD’>Gold </option>
<option value=’GREEN’>Green </option>
<option value=’PURPLE’>Purple </option>
<option value=’BLUE’>Blue </option>
<option value=’NAVY’>Navy Blue </option>
<option value=’ORANGE’>Orange </option>
<option value=’TURQUOISE’>Turquiose </option>
</select> </form>
<br>
</p>
</td>
</tr>
</table> <td>
<table id=”focus” align=”center” style=”height:100px; width:100px; border:3px double black; margin:0 auto;”>
<tr><td></td></tr>
</table>
</td> </tr>
</td>
</tr>
</table>
</body>
</html>
Thanks in advance, Happy Holidays