do not use numbers as id, but try<table><tr>
<td width="30" height="30" id=2230>hello;</td>
<td width="30" height="30" id=2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
<td width="30" height="30" id=2230>hello;</td>
<td width="30" height="30" id=2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
但是运行的时候它提示说:null不是对象
那2个td设了颜色,但不是传递过去的那个颜色,是黑色!
2. and if possible, put the code in onload event handler, like this:<% h="t2230"
states = "red"
%>
<body onload="
setcolor(document.all('<%=h%>'),'<%=states%>');">
<table><tr>
<td width="30" height="30" id=t2230>hello;</td>
<td width="30" height="30" id=t2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}//setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
</body>
但是还是出现"null不是对象"