<tr bgcolor="#f9f9f9">
<td align="left"><span id="Repeater1_ctl02_type1">6</span></td>
<td align="left"><span id="Repeater1_ctl02_type2">14</span></td>
<td align="left"><input id="Repeater1_ctl02_ch" type="checkbox" name="Repeater1$ctl02$ch" /></td>
</tr>         function selectAll() {
            var s = document.getElementById("tb01").getElementsByTagName("input");
            for (var i = 0; i < s.length; i++) {
                if (s[i].type == "checkbox") 
                        {
                    if (s[i].id.indexOf("ch") >= 0&& s[i].checked) 
                            { 
                             //如果这一行选中,怎样获取这一行中id包含type1的值,和id包含type2的值。
                             //得到结果6 和14                            } 
                } 
            }
        }

解决方案 »

  1.   

    楼主为什么不用Jquery呢???var spans = s[i].parentNode.parentNode.getElementsByTagName("span");
    for(var i = 0; i<s.length; i++){
        id = spans[i].id || "";
        if(id.indexOf("type1") >= 0 || id.indexOf("type2"))
        {
             alert(spans[i].innerHTML);
        }
    }
      

  2.   

    楼主为什么不用Jquery呢???var spans = s[i].parentNode.parentNode.getElementsByTagName("span");
    for(var i = 0; i<s.length; i++){
        id = spans[i].id || "";
        if(id.indexOf("type1") >= 0 || id.indexOf("type2"))
        {
             alert(spans[i].innerHTML);
        }
    }
      

  3.   

    var oTbl,tr;
    var strsubmitdate;
    oTbl=document.getElementById("tb01");
    for(var i=1;i<oTbl.rows.length-1;i++){
        tr = oTbl.rows.item(i);
        alert(tr.cells[2].children[0].checked);
    if (tr.cells[2].children[0].checked){alert(tr.cells[1].innerText);//这是datagrid1里面的第一列的值         
      alert(tr.cells[0].getElementsByTagName ('input')[0].value);    //这是绑的一个Textbox的值在第二列
    }
    }
      

  4.   

    "如果这一行选中,怎样获取这一行中id包含type1的值,和id包含type2的值。
                                 //得到结果6 和14"没明白楼主的意思,不就是只有一个input元素吗?怎么又冒出来input.value???
      

  5.   

    js遍历dom是挺烦人的,jquery 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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title><script src='http://code.jquery.com/jquery-latest.js'></script>
    <script type="text/javascript">
    $(function(){
    $('button').click(function(){
    $('table :checked').parent('td').siblings().find('span[id*=type1],span[id*=type2]').each(function(){
    alert($(this).html())
    })
    })
    })</script>
    <style>
    td{
    border:solid 1px red;
    }
    </style></head><body>
    <table>
    <tbody>
    <tr bgcolor="#f9f9f9">
    <td align="left"><span id="Repeater1_ctl02_type1">1</span></td>
    <td align="left"><span id="Repeater1_ctl02_type2">2</span></td>
    <td align="left"><input id="Repeater1_ctl02_ch" type="checkbox" name="Repeater1$ctl02$ch" /></td>
    </tr>
    <tr bgcolor="#f9f9f9">
    <td align="left"><span id="Repeater1_ctl02_type1">3</span></td>
    <td align="left"><span id="Repeater1_ctl02_type2">4</span></td>
    <td align="left"><input id="Repeater1_ctl02_ch" type="checkbox" name="Repeater1$ctl02$ch" /></td>
    </tr>
    </tbody>
    </table>
    <button>getit</button></body>
    </html>