for ( var i = 0; i < oItem.length; i++) {
strId =oItem[i]["ID"]
mytr = mytable.insertRow();
mytr.setAttribute("id", "tr" + iRowIdTemp);
mytr.setAttribute("title",strTitle);
mytr.attachEvent('onclick', function(){selectPat(strId );});
iRowIdTemp++;
var mytdIndex1 = mytr.insertCell();
mytdIndex1.innerHTML = strId
}
function selectPat(strId )
{
alert(strId)
}oItem的值为
oItem[0]["ID"] 0
oItem[1]["ID"] 1当点击表格的行时,还管点哪一行都显示 1我想实现 点第一行是 0 第二行才是 1 也就是显示的是 oItem的值
strId =oItem[i]["ID"]
mytr = mytable.insertRow();
mytr.setAttribute("id", "tr" + iRowIdTemp);
mytr.setAttribute("title",strTitle);
mytr.attachEvent('onclick', function(){selectPat(strId );});
iRowIdTemp++;
var mytdIndex1 = mytr.insertCell();
mytdIndex1.innerHTML = strId
}
function selectPat(strId )
{
alert(strId)
}oItem的值为
oItem[0]["ID"] 0
oItem[1]["ID"] 1当点击表格的行时,还管点哪一行都显示 1我想实现 点第一行是 0 第二行才是 1 也就是显示的是 oItem的值
mytr.setAttribute("id", "tr" + iRowIdTemp);
mytr.setAttribute("title",strTitle);
mytr.setAttribute("strId",oItem[i]["ID"])
mytr.onclick = function () {
selectPat(this.getAttribute("strId"))
}
chenyang37
的方法也报错