这是需要点击的地方,入点“fish”<div id="content-middle">
  <div id="box1"><ul><li><img src="images/detail_08.gif"><input type="button" class="button" value="fish" name="1" onclick="getText(this.name)"></li></ul></div>
  <div id="box2"><img src="images/detail_28.gif"></div><div id="box3"><ul><li><img src="images/detail_11.gif"><input type="button" class="button" value="chicken" name="2" onclick="getText(this.name)"></li></ul></div><div id="box4"><img src="images/detail_28.gif"></div><div id="box5"><ul><li><img src="images/detail_11.gif"><input type="button" class="button" value="egg"></li></ul></div><div id="box6"><img src="images/detail_28.gif"></div>
这是表格,希望在"NAME"命名的表格中显示“fish”,紧挨它的下一个表格显示下一个点击的内容。
<table id="table1" width="240" border="1"  bordercolor="#000000" bgcolor="#FF9933">
  
  <tr>
    <td width="40" height="48" nowrap="nowrap" bordercolor="#000000" bgcolor="#CC3300"><div align="center">NO</div></td>
    <td bgcolor="#CC3300"><div align="center">NAME</div></td>
    <td width="40" nowrap="nowrap" bgcolor="#CC3300"><div align="center">NUM</div></td>
  </tr>
  <tr>
    <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp;</td>
    <td>&nbsp;</td>
    <td width="40" nowrap="nowrap">&nbsp;</td>
  </tr>
  <tr>
    <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp;</td>
    <td>&nbsp;</td>
    <td width="40" nowrap="nowrap">&nbsp;</td>
  </tr>
希望高手看看代码写的有问题吗?然后给把上面的问题解决一下。谢谢了

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script>
    var tabWriteIndex = 1;
    function getText(v){
    var tab = document.getElementById("table1");
    if(tab.rows.length>tabWriteIndex){
    tab.rows(tabWriteIndex++).cells(1).innerText = v;
    }
    }
    </script>
    </head><body>
    <div id="content-middle"> 
      <div id="box1"> <ul> <li> <img src="images/detail_08.gif"> <input type="button" class="button" value="fish" name="1" onclick="getText(this.name)"> </li> </ul> </div> 
      <div id="box2"> <img src="images/detail_28.gif"> </div> <div id="box3"> <ul> <li> <img src="images/detail_11.gif"> <input type="button" class="button" value="chicken" name="2" onclick="getText(this.name)"> </li> </ul> </div> <div id="box4"> <img src="images/detail_28.gif"> </div> <div id="box5"> <ul> <li> <img src="images/detail_11.gif"> <input type="button" class="button" name="3" onclick="getText(this.name)" value="egg"> </li> </ul> </div> <div id="box6"> <img src="images/detail_28.gif"> </div> 
    这是表格,希望在"NAME"命名的表格中显示“fish”,紧挨它的下一个表格显示下一个点击的内容。 
    <table id="table1" width="240" border="1"  bordercolor="#000000" bgcolor="#FF9933"> 
      
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000" bgcolor="#CC3300"> <div align="center">NO </div> </td> 
        <td bgcolor="#CC3300"> <div align="center">NAME </div> </td> 
        <td width="40" nowrap="nowrap" bgcolor="#CC3300"> <div align="center">NUM </div> </td> 
      </tr> 
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp; </td> 
        <td>&nbsp; </td> 
        <td width="40" nowrap="nowrap">&nbsp; </td> 
      </tr> 
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp; </td> 
        <td>&nbsp; </td> 
        <td width="40" nowrap="nowrap">&nbsp; </td> 
      </tr>
      </table></div>
    </body></html>
      

  2.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>test</title>
    <script>
    var tabWriteIndex = 1;
    function getText(v){
        var tab = document.getElementById("table1");
        if(tab.rows.length>tabWriteIndex){
            tab.rows[tabWriteIndex++].cells[1].innerHTML = v;
        }
    }
    </script>
    </head><body>
    <div id="content-middle"> 
      <div id="box1"> <ul> <li> <img src="images/detail_08.gif"> <input type="button" class="button" value="fish" name="1" onclick="getText(this.name)"> </li> </ul> </div> 
      <div id="box2"> <img src="images/detail_28.gif"> </div> <div id="box3"> <ul> <li> <img src="images/detail_11.gif"> <input type="button" class="button" value="chicken" name="2" onclick="getText(this.name)"> </li> </ul> </div> <div id="box4"> <img src="images/detail_28.gif"> </div> <div id="box5"> <ul> <li> <img src="images/detail_11.gif"> <input type="button" class="button" name="3" onclick="getText(this.name)" value="egg"> </li> </ul> </div> <div id="box6"> <img src="images/detail_28.gif"> </div> 
    这是表格,希望在"NAME"命名的表格中显示“fish”,紧挨它的下一个表格显示下一个点击的内容。 
    <table id="table1" width="240" border="1"  bordercolor="#000000" bgcolor="#FF9933"> 
      
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000" bgcolor="#CC3300"> <div align="center">NO </div> </td> 
        <td bgcolor="#CC3300"> <div align="center">NAME </div> </td> 
        <td width="40" nowrap="nowrap" bgcolor="#CC3300"> <div align="center">NUM </div> </td> 
      </tr> 
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp; </td> 
        <td>&nbsp; </td> 
        <td width="40" nowrap="nowrap">&nbsp; </td> 
      </tr> 
      <tr> 
        <td width="40" height="48" nowrap="nowrap" bordercolor="#000000">&nbsp; </td> 
        <td>&nbsp; </td> 
        <td width="40" nowrap="nowrap">&nbsp; </td> 
      </tr>
      </table></div>
    </body></html>