我写的代码,请高手们指教以下。先谢了。
function todaydate()
{
for(var bbb=1;bbb<=6;bbb++)
{
for(var aaa=0;aaa<=6;aaa++)
{if(tableid[7*(bbb-1)+aaa].innerText==myDate)
{
if(global)
{global.style.backgroundColor="";}
else
{tableid[7*(bbb-1)+aaa].style.backgroundColor="#FFCCE6";
global=tableid[7*(bbb-1)+aaa];
selday=myDate;
selxingqi=tableid[aaa].innerText;
break;
}
}
}
}
}
tableid是表格单元格的id ,myDate是今天日期的日。global是全局变量=null。
提示的错误是tableid[]无值。
其实功能就是想选中今天的日子。希望大家能在代码上给谢指点。
问题点数:20、回复次数:5Top
1 楼hbhbhbhbhb1021(天外水火(我要多努力))回复于 2006-03-03 15:18:07 得分 0
这地方不能这么用
改成
document.getElementById("tableid"+[7*(bbb-1)+aaa]).innerTextTop
2 楼happilygirl(快乐苹果)回复于 2006-03-03 15:32:31 得分 0
getElementById是干什么的?Top
3 楼DeluxWorld(曾经的你)回复于 2006-03-03 15:41:12 得分 0
getElementById根据id得到对象,返回的是一个对象~Top
4 楼hbhbhbhbhb1021(天外水火(我要多努力))回复于 2006-03-03 15:41:40 得分 0
就是通过对象的ID来得到对象,并且符合W3C标准
下面是微软的MSDN上写的
getElementById Method Internet Development Index
--------------------------------------------------------------------------------
Returns a reference to the first object with the specified value of the ID attribute.
Syntax
oElement = document.getElementById(sIDValue)
Parameters
sIDValue Required. String that specifies the value of an ID attribute.
Return Value
Returns the first object with the same ID attribute as the specified value.
Remarks
If the ID value belongs to a collection, the getElementById method returns the first object in the collection.
Example
This example uses the getElementById method to return the first occurrence of the ID attribute value, oDiv.
<SCRIPT>
function fnGetId(){
// Returns the first DIV element in the collection.
var oVDiv=document.getElementById("oDiv1");
}
</SCRIPT>
<DIV ID="oDiv1">Div #1</DIV>
<DIV ID="oDiv2">Div #2</DIV>
<DIV ID="oDiv3">Div #3</DIV>
<INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">
Top
5 楼happilygirl(快乐苹果)回复于 2006-03-03 16:24:19 得分 0
可是我用在我的代码里还是不好用呀Top




