动态往另一窗体写table

主窗体

 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script >
    function removeRow(obj)
{
     var clickedRow = obj;

     while(clickedRow.tagName != "TR")
     {
         clickedRow = clickedRow.parentNode;
     }

     clickedRow.parentNode.removeChild(clickedRow);
}

function disval()
{
    var strval;
    var obj;
    strval="";
   
    for(i=0;i<document.getElementsByName("itembox").length;i++)
   {
        obj=document.getElementsByName("itembox")[i];
        if (strval=="")
    {
     strval=obj.value;
 
    }
    else
    {
     
     strval=strval+"|"+obj.value;

    }

   }
  
   alert(strval);
  
}

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type=button  value ="上传附件" onclick ="window.open('default5.aspx');"/>
    <input type=button  value ="显示" onclick ="disval();"/>
    <table id="itemTb">
    <tr>
    <td colspan =2>
    </td>
    </tr>
    </table>
    </div>
    </form>
</body>
</html>

 

子窗体

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <script >
    function taletoTb() {
    var aa=document.getElementById ("txt").value;
    newRow = opener.document.all.itemTb.insertRow(opener.document.all.itemTb.rows.length);
    rowCnt = opener.document.all.itemTb.rows.length;
    newCell = newRow.insertCell();
    newCell.insertAdjacentHTML('BeforeEnd','<div align="center">'+aa+'</div>');
    newCell = newRow.insertCell();
    newCell.insertAdjacentHTML('BeforeEnd','<div align="center">'+aa+'</div>');
    newCell = newRow.insertCell();
    newCell.insertAdjacentHTML('BeforeEnd','<div align="center"><img src="http://www.cnblogs.com/../images/delete2.gif" width="12" height="12" onClick="removeRow(this);"><input type="hidden" name="itembox" value='+aa+'></div>');
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input  type=text id="txt" />
    <input type=button onclick ="taletoTb();"/>
    </div>
    </form>
</body>
</html>

posted on 2009-05-08 10:51  满汗全席  阅读(186)  评论(0编辑  收藏  举报

导航