I HAVE 2个表格(id是dataList和DataArea)2个表格在不同的页面
dataList所在页面 调用 DataArea所在页面
我现在需要把DataArea 加进dataList 如下:
在JAVASCRIPT中:
var temp=self.parent.dataList;--获取父页面中表格
temp.addRows(DataArea);--把DataArea整个当成一行加进去
谁会写addRows(DataArea)这个方法
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var num = 0;//记录已经添加的行数
function addRow()
{
var dataBox = document.getElementById("dataBox");//table
var otr = dataBox.insertRow(1);//参数:table行数-1,在第几行后面增加行
var otd = otr.insertCell();
otd.style.border = "1 solid #000000";
otd.height = "18";
otd.style.bordercolor = "#000000";
var sHTML = "<input type=checkbox id=sel value= >"+num;
otd.innerHTML = sHTML;
for(i=0;i<6;i++){
var otd1 = otr.insertCell();
otd1.style.border = "1 solid #000000";
otd1.height = "18";
otd1.style.bordercolor = "#000000"
var sHTML = i;
otd1.innerHTML = sHTML;
}
num = num + 1
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//delete a row
function delrow()
{
var i = 0,otr;
var dataBox = document.getElementById("databox");
for(i = num-1;i >= 0;i--){
if(sel[i].checked == true){
otr = dataBox.deleteRow(i+1);//删除除表头外的第一行
num = num - 1;
}
}
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//mouse on button
function button_over()
{
var ob=event.srcElement;
if (ob.tagName!="BUTTON")
{
return;
}
ob.className="btnMouseOver";
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//mouse out button
function button_out()
{
var ob=event.srcElement;
if (ob.tagName!="BUTTON")
{
return;
}
ob.className="btnMouseOut";
}
</script>
</head>
<body>
<table id="tblCommandBtn" class="tblCommandBtn" onMouseover="button_over()" onMouseout="button_out()">
<tr>
<td>
<button name="btnAddRow" onclick="addRow()" class = "btnmouseout">增加行</button>
</td>
<td>
<button name="btnDeleteRow" onclick="delrow()" class = "btnmouseout">删除行</button>
</td>
</tr>
</table>
<table width="100%" id="dataBox" class="tblBillDetail" cellspacing="0" cellpadding="0" height="70" border="1">
<tr>
<td width="5%" mce_ bordercolor="#000000" height="22" align="center"> </td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 商品号</td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 商品名称</td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 在库量</td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 数量</td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 计量单位</td>
<td class="tdBillDetailTitle" mce_ bordercolor="#000000" height="22" align="center"> 状态</td>
</tr>
</table>
<button class = "redText">aaa</button>
</body>
</html>
给你参考下