<!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 type="text/javascript">
function add()
{
 //包含所有文件域的DIV
 var div = document.getElementById('te');
  
 //文件域
 var input = document.createElement("textarea");
 //input.id = 'input';
 input.rows = 5 ;
 input.cols = 50 ;
 //添加
 div.appendChild(input);
 }
  
 function add1()
 {
var div = document.getElementById('bu');
var input = document.createElement("input");
input.type='submit';
input.value='发表';
//添加
  div.appendChild(input);
 }
  function button()
  {
document.getElementById("submit").style.display="none";
//这里按钮隐藏起来
  }
</script>
</head>
<body>
<div style=" width:1000px;margin: 0 auto;">
  <?
  $file=array('台式机多少钱?','笔记本咋卖的?','显卡有货没?');
  foreach ($file as $kk)
  {?>
  <ol style="border-bottom:#0C0 1px solid;color:#0000ff; width:980px;">
  <li style=" list-style-type:none;">
  <?=$kk?>
  </li>
  </ol>
  <ol>
  <form method="POST" enctype="multipart/form-data" action="upload.php">
  <input type="button" id="submit" onclick="add();add1();button();" value="回复"/>
  <div id="te"> </div>
  <div id="bu" style="margin-left:150px; margin-top:10px;"> </div>
  </form>
  </ol>
  <?
  
  }
    
  ?>
</div>
</body>
</html>问题:1 点击回复都是在第一条信息下弹出回复框,怎样才能在当前信息下弹出?
     2 点击回复第二条信息,发现点错了要回复第三条信息.当点击第三条信息时原来弹出的回复框自动消失.也就是一次只能
       有一条回复框。                                    谢谢!
补充:类似网易这样的留言效果 请高人指点.
http://weiyingjie1974.blog.163.com/blog/static/130049112201142210923692/?zhuanlan

解决方案 »

  1.   


    <!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>
    </head>
    <script>
    function $(el){return document.getElementById(el)};
    function response(obj)
    {
    var oComment=obj.parentNode;//这里是关键。找到当前留言对象。
    oComment.appendChild($("response"));
    $("response").style.display="block";
    }
    </script>
    <div>
    <div>
    我是一条评论
    <div onclick="response(this);cursor:pointer;" style="color:red;cursor:pointer;">回复</div>
    </div>
    <div>我是一条评论<div onclick="response(this);" style="color:red;cursor:pointer;">回复</div></div>
    <div>我是一条评论<div onclick="response(this);" style="color:red;cursor:pointer;">回复</div></div>
    <div>我是一条评论<div onclick="response(this);" style="color:red;cursor:pointer;">回复</div></div>
    <div>我是一条评论<div onclick="response(this);" style="color:red;cursor:pointer;">回复</div></div>
    </div>
    <div id="response" style="display:none;">
    <textarea style="width:300px;height:150px"></textarea>
    <input value="提交" type="submit" />
    </div>
    </body>
    </html>
      

  2.   

    要做取消就再加一个函数,加一个取消的按钮来触发,把response对象style换成none。
      

  3.   

    看起来好简洁呀 一直在php论坛混 这里也要多逛逛了 js ajax 唉 想想头都大了 精力有限 学的东西无限 非常感谢!