一个评分控件的错误,请帮忙改正一下
[code=JScript][/code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript">
function initEvent(){
var table=document.getElementById("Gread");
var tds=table.getElementsByTagName("td");
for(var i=0;i<tds.length;i++){
var td=tds[i];
td.onclick=changeColor;
td.style.cursor="pointer";
}
}
function changeColor(){
var table=document.getElementById("Gread");
var tds=table.getElementsByTagName("td");
var index=indexof(tds,this);
for(var i=0;i<=index;i++){
var td=tds[i];
td.style.background="red";
}
for(var j=index+1;j<=tds.length;j++){//5个星星时候怎么办
var td=tds[i];
td.style.background="white";
}
}
function indexof(arry,element){
for(var i=0;i<arry.length;i++){
if(arry[i]==element){
return i;
}
}
}
</script>
</head>
<body onload="initEvent()">
<table id="Gread">
<tr>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
<td>
?
</td>
</tr>
</table>
</body>
</html>
//Line: 26
//Error: Unable to get value of the property 'style': object is null or undefined(这个是网页的错误提示请问我应该怎么改啊!)
------解决方案--------------------
JScript code
for (var j = index + 1; j <= tds.length; j++) {//5个星星时候怎么办
var td = tds[i];
if (i <=4) { td.style.background = "white"; }
else {return false;}