JS子頁面操作父頁面table 新增行並傳值
function Test(array)
{
var j=0;
var tab =window.opener.document.getElementById("tab1");
for(var i=1;i<tab.rows.length;i++)
{
if(tab.rows[i].cells[1].innerText.replace(' ',"")==array[0].replace(' ',"").toString())
{
j++;
}
}
if(j>0)
{
if(!window.confirm("該款號已新增,還要新增嗎?"))
{
return true;
}
}
AddRow(array)
}
function AddRow(array)
{
//新增一行
var tab1 =window.opener.document.getElementById("tab1");
var i =tab1.rows.length;
var Nam="'div1'";
var Cod="fuJ"+i;
var newTr=tab1.insertRow();
//新增列
var newTd0 = newTr.insertCell();
var newTd1 = newTr.insertCell();
var newTd2 = newTr.insertCell();
var newTd3 = newTr.insertCell();
var newTd4 = newTr.insertCell();
var newTd5 = newTr.insertCell();
var newTd6 = newTr.insertCell();
var newTd7 = newTr.insertCell();
var newTd8 = newTr.insertCell();
//設定列內容和屬性
newTd0.innerHTML = "<input width='100px' type='checkbox' id='box1' onClick='enableItemButton();'/>" ;
newTd1.innerText =array[0];
newTd2.innerText =array[1];
newTd3.innerText =array[2];
newTd4.innerHTML ="<input type ='text' title='雙擊選擇顏色' onkeydown='event.returnValue=false;' ondblclick='OpenColor();' value='' id ='a' style='width:90px ; height: 20px ;border-right: 0px;border-top: 0px;border-left: 0px;border-bottom: black 1px solid'/> "
newTd5.innerHTML ="<input type ='text' onkeyup='if(isNaN(value))execCommand(/"undo/"); total();' onkeypress='enablebtn();' onkeypress='enablebtn();' id ='b' style='width:90px ; height: 20px ;border-right: 0px;border-top: 0px;border-left: 0px;border-bottom: black 1px solid'/> "
newTd6.innerHTML = "<input type ='text' onkeyup='if(isNaN(value))execCommand(/"undo/"); total();' onkeypress='enablebtn();' id ='c' style='width:90px ; height: 20px ;border-right: 0px;border-top: 0px;border-left: 0px;border-bottom: black 1px solid'/> " ;
newTd7.innerText="";
newTd8.innerHTML="<input type ='text' id ='c' style='width:90px ; height: 20px ;border-right: 0px;border-top: 0px;border-left: 0px;border-bottom: black 1px solid'/> ";
}