<script>
function fmouseover(obj)
{
document.all.td2.innerText=obj.innerText+"sdf"
  
}
function fonmouseout(obj)
{document.all.td2.innerText="";}</script>
<body>
<table>
  <tr>
    <td onmouseover="fmouseover(this)" onmouseout="fonmouseout(this)">something</td>
    <td id="td2"></td>
  </tr>
</table>
<input type="button" onclick=fb() value="oooo">
</body>

解决方案 »

  1.   

    <table>
      <tr>
        <td onmouseover="func(this)" onmouseout="">something</td>
        <td></td>
      </tr>
    </table>
    </BODY>
    function func(a){
    alert("123")
    alert(a.innerHTML)
       alert(a.parentNode.childNodes[1].innerText="123132")
    }
      

  2.   

    <table>
      <tr>
        <td onmouseover="document.all.td2.innerHTML='test';" onmouseout="document.all.td2.innerHTML='';">something</td>
        <td></td>
      </tr>
    </table>
      

  3.   

    <table>
      <tr>
        <td onmouseover="document.all.td2.innerHTML='test';" onmouseout="document.all.td2.innerHTML='';">something</td>
        <td></td>
    <td id='td2'></TD>
      </tr>
    </table>
      

  4.   

    <table>
      <tr>
        <td onmouseover="func(this)" onmouseout="">something</td>
        <td></td>
      </tr>
    </table>
    </BODY>
    function func(a){
    alert("123")
    alert(a.innerHTML)
       a.parentNode.childNodes[1].innerText="123132"
    }
      

  5.   

    谢谢大伙!我正在尝试……
    BTW,JS内可以嵌套PHP吗?
      

  6.   

    又想到一个问题:在当前页面上作某些操作,怎么在另一个页面写入东西呢?
    比如,在当前页面,有<form onsubmit="aFunc()">,提交这个form后,在另一个页面的一个table中的cell中写入东西
      

  7.   

    <table>
      <tr>
        <td>something</td>
        <td><% $_POST('textName') %></td> //php 
      </tr>
    </table>也可  <body onlody="func()">
    function func(){
    document.getElementById("td2").value="1231"
         
    }<table>
      <tr>
        <td>something</td>
        <td id="td2"></td>
      </tr>
    </table>
      

  8.   

    mingxuan3000(铭轩),我觉得好像不行呢,比如,我是在page1提交form,然后是page2中的table的一个cell内容改变(也就是向这个cell中写入内容了吧),在page1的某个函数中,用document.getElementById("td_id")能获得page2中的这个cell吗?而且,还有一点要求是,如果刷新page2,cell中的内容应该是原来的内容,不是上次提交page1的form后写入的内容
      

  9.   

    就是说,通过page1上的form的提交,改写page2的一个table cell的内容,只是在客户端,不保存到服务器上,所以不能用PHP吧
    mingxuan3000(铭轩),还有各位,有什么好办法吗
      

  10.   

    window.open()打开的页面,可以不经后台取值,window.opener
      

  11.   

    也似乎不能用window.open(),因为顺序是,用户会先到上面所说的page2,然后才会到page1,并在page1提交form,提交后,会在page2看到提交的部分内容,也就是写入到page2的table cell中的内容
    谢谢mingxuan3000(铭轩)!
      

  12.   

    我是在page1提交form,然后是page2中的table的一个cell内容改变(也就是向这个cell中写入内容了吧),在page1的某个函数中,用document.getElementById("td_id")能获得page2中的这个cell吗?
    这是不行的
      

  13.   

    再问一下,如果用session保存page1提交的内容可行吗,大伙觉得
      

  14.   

    大伙帮忙看看这段代码,就是想通过onclick事件替换一些table cell的内容,只在前台,不能涉及后台,所以用JS了,但不能成功,也就是向要替换的table cell的内容不变(比如点选了goalkeeper1后,“守门员一”变成“goalkeeper1”)===================== start =================================<body>
      <table width="100%" height="100%">
        <tr>
          <td width="75%">
            <table width="75%" height="100%" background="pitchf1.gif" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td rowspan="6" id="goalkeeper1">守门员一</td>
                <td id="guard1">后卫一</td>
                <td id="midfield1">中场一</td>
                <td id="front1" rowspan="2">前锋一</td>
              </tr>
              <tr>
                <td id="guard2">后卫二</td>
                <td id="midfield2">中场二</td>
                <td id="front2" rowspan="2">前锋二</td>
              </tr>
              <tr>
                <td id="guard3">后卫三</td>
                <td id="midfield3">中场三</td>
                <td id="front3" rowspan="2">前锋三</td>
              </tr>
              <tr>
                <td id="guard4">后卫四</td>
                <td id="midfield4">中场四</td>
              </tr> 
              <tr>
                <td id="guard5">后卫五</td>
                <td id="midfield5">中场五</td>
              </tr> 
              <tr>
                <td id="guard6">后卫六</td>
                <td id="midfield6">中场六</td>
              </tr>          
            </table>
          </td>
          <td width="25%">
            <form name="poll" action="<?php echo $PHP_SELF; ?>" method="post" onsubmint="process()">
              <select name="goalkeeper" language="JavaScript" onchange="">
                <option value="" selected>守门员</option>
                <option value="goalkeeper1" onclick="document.getElementById('goalkeeper1').value='goalkeeper1'">goalkeeper1</option>
                <option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper2'">goalkeeper2</option>
                <option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper3'">goalkeeper3</option>
                <option value="" onclick="document.getElementById('goalkeeper1').value='goalkeeper4'">goalkeeper4</option>
              </select><br />
              <select name="guard" language="JavaScript" onchange="">
                <option value="" selected>后卫</option>
                <option value="guard1" onclick="document.getElementById('guard1').value='guard1'">guard1</option>
                <option value="guard2" onclick="document.getElementById('guard2').value='guard2'">guard2</option>
                <option value="guard3" onclick="document.getElementById('guard3').value='guard3'">guard3</option>
                <option value="guard4" onclick="document.getElementById('guard4').value='guard4'">guard4</option>
                <option value="guard5" onclick="document.getElementById('guard5').value='guard5'">guard5</option>
                <option value="guard6" onclick="document.getElementById('guard6').value='guard6'">guard6</option>
              </select><br />
              <select name="midfield" language="JavaScript" onchange="">
                <option value="" selected>中场</option>
                <option value="midfield1" onclick="document.getElementById('midfield1').value='midfield1'">midfield1</option>
                <option value="midfield2" onclick="document.getElementById('midfield2').value='midfield2'">midfield2</option>
                <option value="midfield3" onclick="document.getElementById('midfield3').value='midfield3'">midfield3</option>
                <option value="midfield4" onclick="document.getElementById('midfield4').value='midfield4'">midfield4</option>
                <option value="midfield5" onclick="document.getElementById('midfield5').value='midfield5'">midfield5</option>
                <option value="midfield6" onclick="document.getElementById('midfield6').value='midfield6'">midfield6</option>
              </select><br />
              <select name="front" language="JavaScript" onchange="">
                <option value="" selected>前锋</option>
                <option value="front1" onclick="document.getElementById('front1').value='front1'">front1</option>
                <option value="front2" onclick="document.getElementById('front2').value='front2'">front2</option>
                <option value="front3" onclick="document.getElementById('front3').value='front3'">front3</option>
              </select><br />
              <input type="submit" name="submint" value="提交" />
              <input type="reset" name="reset" value="重选" />
            </form>  
          </td>
        </tr>
      </table>
    </body>
    =================== end =================================
      

  15.   

    <select name="goalkeeper" language="JavaScript" onchange="func(this)">
                <option value="" selected>守门员</option>
                <option value="goalkeeper11" >goalkeeper1</option>
                <option value="goalkeeper12" >goalkeeper2</option>          </select>
    function func(a){
    if(a.value=="goalkeeper11"){
    document.getElementById('goalkeeper1').value='goalkeeper1'
    }
    }
    <option>里的onclick事件不响应的
      

  16.   

    mingxuan3000(铭轩),还有更好的办法吗,因为不是固定住只选goalkeeper1的,所以,如果用上面的函数func(a),就需要些很多if语句或者switch语句另外,<option>里onselect事件响应吗
      

  17.   

    =============== codes start ===============
    <html>
    <head>
      <script language="JavaScript" type="text/javascript">
        function func(a)
        {
            if(a.value=="goalkeeper1")
                document.getElementById('goalkeeper1').value='goalkeeper1';
        }
      </script>
    </head><body>
      <table><tr><td id="goalkeeper1">守门员一</td></tr></table>
      <form>
        <select language="JavaScript" onchange="func(this)">
          <option value="goalkeeper1">goalkeeper1</option>
          <option selected>sth</option>
        </select>
    </body>
    </html>
    ================ codes end ======================按上面这样试了一下,还是不行呢,“守门员一”并没有被替换成“goalkeeper1”
      

  18.   

    function func(a)
        {
            if(a.value=="goalkeeper1")
                document.getElementById('goalkeeper1').innerText='goalkeeper1';
        }