onClick="Javascript:tablestyle(-1);
关键就是如何保存上次的值.实际上-1应该用一个变量表示,可这步不知道如何写了.请帮帮忙了.

解决方案 »

  1.   

    <script>
    function aa(){
    var a=window.document.table1.a.backgroundColor=rgb:#ffffff
                 }
    function bb(){
    var a=window.document.table1.a.backgroundColor=rgb:#000000
                 }
    }
    </script>
    <table id="table1">
    <tr>
    <td id=a>aaaaaaaaaaa</td>
    </tr>
    </table>
    <img src="hei.jpg" onclick=aa()>
    <img src="hong.jpg" onclick=bb()>
      

  2.   

    呵呵,我搞定了.
    <script>
    var  index;
    index=0;
    function index1()
    {
    document.all.table1[index].style.backgroundColor="";
    index--;
    tablestyle();
    }
    function index2()
    {
    document.all.table1[index].style.backgroundColor="";
    index++;
    tablestyle();
    }
    function tablestyle()
    {
    var indexcount=document.all.table1.length-1;
    if(index<0)
    {
    index=indexcount;
    }
    if(index>indexcount)
    {
    index=0;
    }
    document.all.table1[index].style.backgroundColor="#eee7F7";
    }
    </script>
    </head><body>
    <a href="javascript:getwindow('cxzl.asp',150,200);">asdfasdf</a>
    <table width="100%"  border="0">
      <tr>
        <td  colspan="2"><table width="100%"  border="1" cellspacing="0">
            <tr id="table1">
              <td>&nbsp;</td>
            </tr>
            <tr id="table1">
              <td>&nbsp;</td>
            </tr>
            <tr id="table1">
              <td>&nbsp;</td>
            </tr>
            <tr id="table1">
              <td>&nbsp;</td>
            </tr>
            <tr id="table1">
              <td>&nbsp;</td>
            </tr>
            <tr id="table1"> 
              <td>&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><P id="index1" onClick="Javascript:index1();" style="cursor:hand">上一条</a></td>
        <td><P id="index2" onClick="Javascript:index2();" style="cursor:hand">下一条</a></td>
      </tr>
    </table>
      

  3.   

    <html>
    <head>
    <script>
    var curRow=null;   //全局行号
    function selectRow(tr1){
    if(curRow)
    curRow.bgColor="#FFFFFF";
    tr1.bgColor="#eee7F7";
    curRow=tr1;
    }function preRow(){
    var tbRows=table1.rows;
    if(curRow){
    var curRowIndex=curRow.rowIndex;
    if(curRowIndex==0) tbRows[tbRows.length-1].click();
    else tbRows[curRowIndex-1].click();
    }else
    tbRows[0].click();
    //#eee7F7
    }
    function nextRow(){
    var tbRows=table1.rows;
    if(curRow){
    var curRowIndex=curRow.rowIndex;
    if(curRowIndex==tbRows.length-1) tbRows[0].click();
    else tbRows[curRowIndex+1].click();
    }else
    tbRows[0].click();
    }
    </script>
    </head>
    <body>
    <table width="100%"  border="0">
      <tr>
        <td  colspan="2">
    <table id="table1" width="100%"  border="1" cellspacing="0" style="border-collapse:collapse " bordercolor="#333333">
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
             <tr onClick="selectRow(this)"><td>&nbsp;</td></tr>
         </table>
    </td>
      </tr>
      <tr>
        <td align="right"><a style="cursor:hand " onClick="preRow()"><font color="blue">上一条</font></a></td>
        <td><a onClick="nextRow()" style="cursor:hand "><font color="blue">下一条</font></a></td>
      </tr>
    </table>
    </html>