I am trying to alter the background color of a table cell if the selected item in a dropdown is changed. I use the same javascript for a textbox and it works fine. In firebug, "cell" is undefined when called from the select.
Here is my script/html
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function changeText(cell, shown, hidden)
{
if (shown == hidden)
{
cell.style.backgroundColor="red";
}
else
{
cell.style.backgroundColor="green";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="5">
<tr>
<td>
Cell 1
</td>
<td>
<select id="catBlah" OnChange="changeText(this.parentnode, this.options[this.selectedIndex].value, '789');">
<option value=""></option>
<option selected="selected" value="789">Item 1</option>
<option value="000">Item 2</option>
<option value="456">Item 3</option>
<option value="123">Item 4</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="text" value="blue" onchange="changeText(this.parentNode, this.value, 'blue');" />
</td>
<td>
Cell 4
</td>
</tr>
</table>
</form>
</body>
</html>
If I just pass the select object (using "this" instead of "this.parentnode"), I can change the select's background color (which might meet requirements), but I can't figure out how to get the parentnode.
Thanks
It's parentNode
(note the casing)