没有办法点击两个checkbox后  点击submit 把这两个邮件地址插入插入form的text中
<html>
<body>
<h3>phpmailer Test</h3><form name="phpmailer" action="send.php" method="post">
<input type="hidden" name="submitted" value="1"/>
email: <input type="text" size="50" name="address" /><br>
titie: <input type="text" size="50" name="title" /><br>
content: <input type="text" size="50" name="content" />
<br/>
<input type="submit" value="发送"/></form><script>
    var add =    function(id)
    {
        if(document.getElementById("address").value==""){
           document.getElementById("address").value=id.innerHTML;
        }else{
           document.getElementById("address").value+=";"+id.innerHTML;
        }
    }
</script>
<table border=1>
<tr>
<td><input type="checkbox" size="50" name="address" /></td>
<td>lixuenong</td>
<td><a href="javascript:void(1)" onClick="return add(this);">[email protected]</a></td></tr><tr>
<td><input type="checkbox" size="50" name="address" /></td>
<td>lixn</td>
<td><a href="javascript:void(1)" onClick="return add(this);">[email protected]</a></td></tr></table><input type="submit" value="插入地址"/>------------------有没有办法点击两个checkbox后把这两个地址插入插入form中
</body>
</html>

解决方案 »

  1.   

    我是要选了checkbox 然后点击submit再插入,不是直接点地址插入
      

  2.   


    <html>
    <body>
    <h3>phpmailer Test</h3>
    <form name="phpmailer" action="send.php" method="post">
    <input type="hidden" name="submitted" value="1"/>
    email: <input type="text" size="50" name="address" id='address'/><br>
    titie: <input type="text" size="50" name="title" /><br>
    content: <input type="text" size="50" name="content" />
    <br/>
    <input type="submit" value="发送"/>
    </form>
    <script>
      function add()
      {
      var  divObj = document.getElementsByTagName('input'); 
      var  strEmail = "";
    for(var i=0; i< divObj.length; i++)   
        {   
            if(divObj[i].type == 'checkbox' && divObj[i].name=='address1[]' && divObj[i].checked)   
            {
              if(strEmail != "")
              { 
                 strEmail +=  ";";
              }
              strEmail += divObj[i].value;
            }
        } 
        document.getElementById("address").value = strEmail;
      }
    </script>
    <table border=1>
    <tr>
    <td><input type="checkbox" size="50" name="address1[]" value="[email protected]"/></td>
    <td>lixuenong</td>
    <td>[email protected]</td></tr>
    <tr>
    <td><input type="checkbox" size="50" name="address1[]" value="[email protected]"/></td>
    <td>lixn</td>
    <td>[email protected]</td></tr></table>
    <input type="button" value="插入地址" onclick="add();"/>
    </body>
    </html>