<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="kikimail.WebForm1" %><!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 runat="server">
    <title></title>
                         <script type="text/javascript">
                             function GroupTableCreat() {
                                 var divt = document.getElementById("divUserGroup");
                                 var tablet = "<table cellspacing='0' rules='all' border='0' id='grvContent2' style='position:relative;left:45pt;border-width:0px;width:80%;border-collapse:collapse;'><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk0' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk1' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk2' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk3' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk4' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk5' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk6' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk7' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk8' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk9' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk10' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk11' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr></table>";
                                 divt.appendChild(tablet);
                         }
                         
                         </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr><td><input type="button" value="copy" onclick="GroupTableCreat();" /></td></tr>
    </table>    
    </div>
    <div>
    <table cellspacing='0' rules='all' border='0' id='grvContent' style='position:relative;left:45pt;border-width:0px;width:80%;border-collapse:collapse;'><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk0' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk1' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk2' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk3' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk4' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk5' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk6' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk7' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk8' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk9' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk10' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk11' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr></table>
    </div>
    <div id="divUserGroup">
    
    </div>
    </form>
</body>
</html>
代码如上,点击copy按钮时抱错;
需要追加的table显示是没有任何问题的,但是往div中添加就嫁不上去,抱错了

解决方案 »

  1.   

    tablet不是对象,是字符串,所以不行。修改一下, 转成对象类型即可                             function GroupTableCreat() {
                                     var divt = document.getElementById("divUserGroup");
                                     var tablet = "<table cellspacing='0' rules='all' border='0' id='grvContent2' style='position:relative;left:45pt;border-width:0px;width:80%;border-collapse:collapse;'><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk0' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk1' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk2' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk3' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk4' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk5' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk6' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk7' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr><tr class='t_row_bg'><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk8' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk9' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk10' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td><td class='Cell_Normal' align='center' style='width:5%;'><input type='checkbox' name='chk11' /></td><td class='Cell_Normal' align='left' style='width:15%;'>on</td></tr></table>";
     var wrap = document.createElement("div");
     wrap.innerHTML = tablet;
     var tab = wrap.childNodes;
                                     divt.appendChild(tab[0]);
                             }
      

  2.   

    divt.appendChild(tablet);
    改成
    divt.innerHTML=tablet;
    试试
      

  3.   

    对滴,用jquery的话是可以这么干的,直接append(tablet);