<script> 
function PerformSubmit(user) {
  document.chatForm.msgTo.value=user;
  return false;}
</script>
<a href="#" onclick="PerformSubmit('a')" >a</a>
<a href="#" onclick="PerformSubmit('b')" >b</a>
<form name="chatForm"  method="post" >
<input type="text" name="msgTo" >
先点击 a  然后点击 b    
在 input  text  中显示  a,b
这个怎么实现 请高手指点

解决方案 »

  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><body>
    <script>
    function PerformSubmit(user) {
      document.chatForm.msgTo.value+=user;
      return false;}
    </script>
    <a href="#" onclick="PerformSubmit('a')" >a</a>
    <a href="#" onclick="PerformSubmit('b')" >b</a>
    <form name="chatForm" method="post" >
    <input type="text" name="msgTo" >
    </body>
    </html>
      

  2.   

    <input type="text" name="msgTo" >改成<input type="text" id="msgTo" >
      

  3.   


    <script> 
    var i=0; 
    function PerformSubmit(user) {
      if(i){document.chatForm.msgTo.value+=",";}
      i=1;
      document.chatForm.msgTo.value+=user;
      return false;
    }
    </script>
    <a href="#" onclick="PerformSubmit('a')" >a</a>
    <a href="#" onclick="PerformSubmit('b')" >b</a>
    <form name="chatForm" method="post" >
    <input type="text" name="msgTo" >