05/08/31 08:09:30
>>244
正直スマートな方法が思いつかんが
function getParentNode(_o, _t)
{
_t = _t.toUpperCase();
while (_o.tagName != _t) _o = _o.parentNode;
return _o;
}
function getRootRowIdx(_o)
{
var currentTabale = getParentNode(_o, "table");
var parentTr = getParentNode(currentTabale, "tr");
return parentTr.rowIndex;
}
function getButtonNum(_o, _name)
{
var elmz = document.body.getElementsByTagName("input");
var i, idx = -1;
for (i=0; i<elmz.length; i++)
if (elmz[i].name == _name)
{
idx++;
if (elmz[i] == _o) break;
}
return idx;
}
function func(_o) // onclick="alert( func(this) );"
{
var rowIdx = getRootRowIdx(_o); // rowIndex を取得
var btnIdx = getButtonNum(_o, "c"); // ボタンのインデックスを取得
}