function getDetail(seq) {
 .......
}
window.onload=function(){ 
    var tab = document.getElementById("tab"); 
    for(var i=0;i <tab.rows.length;i++) 
    { 
        tab.rows[i].onclick = function(){ 
            if(tab.temp) 
                tab.temp.style.backgroundColor = ""; 
                调用另一个js函数, 有参数传入 <getDetail(seq)>
            this.style.backgroundColor = "#cccccc"; 
                tab.temp = this; 
        } 
    } 

我希望, 在这个事件中, 可以调用getDetail的函数, 得到明细

解决方案 »

  1.   

    可以直接调用getDetail函数的啊
      

  2.   

    window.onload=function(){ 
        var tab = document.getElementById("tab"); 
        for(var i=0;i <tab.rows.length;i++) 
        { 
            tab.rows[i].onclick = function(){ 
                if(tab.temp) 
                    tab.temp.style.backgroundColor = ""; 
                    getDetail(seq)             this.style.backgroundColor = "#cccccc"; 
                    tab.temp = this; 
            } 
        } 

    可以直接这样啊
      

  3.   

    那么seq该如何传入呀,我想问的是这个
      

  4.   


    晕,你平常是怎么把那个值传给getDetail的?
      

  5.   

    把要传递的参数作为table的属性就可以了,那样直接取单击表格的相应属性就可以了
      

  6.   

    直接调用函数就可以了,晕,
    如果想传入参数的话,就先设置全局变量,然后将该变量放入该函数里
    function getDetail(seq) { 
    ....... 

    var seq;
    seq='hao123';
    window.onload=function(){ 
        var tab = document.getElementById("tab"); 
        for(var i=0;i <tab.rows.length;i++) 
        { 
            tab.rows[i].onclick = function(){ 
                if(tab.temp) 
                    tab.temp.style.backgroundColor = ""; 
                    getDetail(seq);
                this.style.backgroundColor = "#cccccc"; 
                    tab.temp = this; 
            } 
        } 
      

  7.   

    <html xmlns="http://www.w3.org/1999/xhtml"><head>
     <script>
    function getDetail(id)
    {
        alert(id);
    }
    window.onload=function(){ 
        var tab = document.getElementById("tab"); 
        for(var i=0;i <tab.rows.length;i++) 
        { 
            tab.rows[i].onclick = function(){ 
                if(tab.temp) 
                   //现在我只能给你做到这一步了,tab.rows(行id).cells(列id).innerText就能取出某个行所有列的值
                   //如果只有行的话就直接tab.rows(行id).innerText;
                   
                    tab.temp.style.backgroundColor = ""; 
                    getDetail(tab.rows(0).innerText);             
                    this.style.backgroundColor = "#cccccc"; 
                    tab.temp = this; 
            } 
        } 

    </script>
    </head>
    <body><table id="tab">
    <tr><td>11111111111111111</td></tr>
    <tr><td>11111111111111111</td></tr>
    <tr><td>11111111111111111</td></tr>
    <tr><td>22222222222222222</td></tr>
    </table></body>
    </html>你就是在控制一下你点击后的那个行索引,得到那个多少行就行了
    现在我只是写的点击第一行获取的值,
      

  8.   


    这个应该比较齐全了,随便点击table 里的哪一行都显示出那行的所有相信信息
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
     <script>
    function getDetail(id)
    {
        alert(id);
    }
    window.onload=function(){ 
        var tab = document.getElementById("tab").getElementsByTagName("tr"); 
        for(i=0;i <tab.length;i++) 
        { 
            tab[i].onclick = function(){ 
                //alert("行:"+eval(this.rowIndex));
                var count=eval(this.rowIndex);
                if(tab.temp)
                     tab.temp.style.backgroundColor = ""; 
                     getDetail(tab[count].innerText);             
                     this.style.backgroundColor = "#cccccc"; 
                     tab.temp = this; 
            } 
        } 

    </script>
    </head>
    <body><table id="tab">
    <tr ><td>11111111111111111</td><td>中国</td></tr>
    <tr ><td>11111111111111111</td><td>英国</td></tr>
    <tr ><td>11111111111111111</td><td>法国</td></tr>
    <tr ><td>22222222222222222</td><td>德国</td></tr>
    </table></body>
    </html>
      

  9.   

    还是有问题, 我要传递的参数, 没有在table里面, 是用javabean传递到页面的,这样做不到呀。
      

  10.   

    你把传到页面的值放在某个控件里面嘛

    <font id="va">你传进来的值</font>然后到你的函数里面取function getDetail(seq) { 
    ....... 

    window.onload=function(){ 
        var tab = document.getElementById("tab"); 
        for(var i=0;i <tab.rows.length;i++) 
        { 
            tab.rows[i].onclick = function(){ 
                if(tab.temp) 
                    tab.temp.style.backgroundColor = ""; 
                    var v=document.getaElementByID("va").value;
                    getDetail(v) ;
                this.style.backgroundColor = "#cccccc"; 
                    tab.temp = this; 
            } 
        } 

      

  11.   

    首先, 有很多行的, 每行对应一个id, 选择不同的行,会对应不同的id的噢, 还有, 我不太愿意, 把关键的传值放入到控件中来做,这样不安全。
      

  12.   

    服务器端的变量可以传给JS的
    就拿ASP的来说吧
    <%a=1%>
    <script>
    var str="<%=a%>";
    </script>