getarr(this)function getarrr(o)
{
alert(o.id)
}

解决方案 »

  1.   

    function getarrr(o)
    {
    for(i=0;i<document.getElementsByTagName("TD").length;i++)
    if(document.getElementsByTagName("TD")[i].id=="aa") alert("ok")
    alert(o.parentElement.rowIndex)
    alert(o.cellIndex)
    }
      

  2.   

    那要是把TD换成IMG或INPUT就不行了啊
      

  3.   

    为什么要换成img或者input???
    是把他们放到TD中吗?
    始终不太明白你的用意
      

  4.   

    其实是这样的 我想列出N个select  当选择其中一个的一个项目时提示出选的是第几个SELECT和第几个OPTIONS  然后就那TD来试 没试出来就帖出来问问  没想到在TD中好使  在SELECT中就不行了  还请大家再帮帮忙
      

  5.   

    可以这样,你把所有的select的id按顺序编号,这样方便对号入座。
    function getarrr(o)
    {
    alert(o.id);
    alert(o.selectedIndex);
    }
    看看时不是呢?
      

  6.   

    <html>
    <head>
    <script>
    function getCount(name) {
    var num = 0;
    var objs = document.all.item(name);
    if (objs!=null)
    num = (typeof(objs.length)=="undefined"?1:objs.length);
    return num;
    }
    function getarr() {
    var objTD = event.srcElement;
    while (objTD!=null && objTD.tagName!="TD")
    objTD = objTD.parentElement;
    if (objTD!=null) {
    var objTR = objTD;
    while (objTR!=null && objTR.tagName!="TR")
    objTR = objTR.parentElement;

    if (objTR!=null)
    alert("id=" + objTD.id + ", 个数=" + getCount(objTD.id) + ", 行=" + objTR.rowIndex + ", 列=" + objTD.cellIndex);
    }
    }
    document.onclick = getarr;
    </script>
    </head><body>
    <table border="1" align="center" cellpadding="0" cellspacing="0" >
    <tr>
    <td id="A" width="80" height="80">1</td>
    <td id="B" width="80" height="80">2</td>
    <td id="C" width="80" height="80">3</td>
    <td id="D" width="80" height="80">4</td>
    <td id="E" width="80" height="80">5</td>
    </tr>
    <tr>
    <td id="F" width="80" height="80">6</td>
    <td id="E" width="80" height="80">7</td>
    <td id="D" width="80" height="80">8</td>
    <td id="C" width="80" height="80">9</td>
    <td id="B" width="80" height="80">0</td>
    </tr>
    </table>
    </body>
    </html>
      

  7.   

    因为JS动态的生成SELECT 所以ID和NAME都是同名的
      

  8.   

    <html>
    <head>
    <script>
    function getarr(obj) {
    var objs = document.getElementsByTagName("SELECT");
    for (var i=0; i<objs.length; i++) {
    if (obj==objs[i]) {
    alert("第" + (i + 1) + "个SELECT, 第" + (objs[i].selectedIndex + 1) + "个选项");
    break;
    }
    }
    }
    </script>
    </head><body><select onchange="getarr(this)">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select><select onchange="getarr(this)">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select><select onchange="getarr(this)">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>
    </body>
    </html>