从一个页面把值传到另一个页面,要把值在表格里边显示出来,表格是动态生成的; 代码如下:
生成一行的代码,要把值传过来之后,显示在表格,点击图中添加商品按钮,就会执行addItem()函数,然后把从另一个页面的传过来,显示在表格里边,functionaddIt...
生成一行的代码,要把值传过来之后,显示在表格,点击图中添加商品按钮,就会执行addItem()函数,然后把从另一个页面的传过来,显示在表格里边,
function addItem(){
var detailList = document.getElementById("detailList");
var i=detailList.rows.length;
var row = detailList.insertRow(i);
var rowIndex = detailList.rows[i].rowIndex;
var j=k;
detailList.rows[i].setAttribute("align","center");
detailList.rows[i].setAttribute("bgcolor","#FFFFFF");
detailList.rows[i].setAttribute("id","tr"+j);
detailList.rows[i].insertCell(0);
var text = document.createTextNode(rowIndex-1);
detailList.rows[i].cells[0].appendChild(text);
detailList.rows[i].insertCell(1);
var input10 = document.createElement("input");
input10.setAttribute("type","hidden");
input10.setAttribute("name","productId");
input10.setAttribute("id","productId"+j);
detailList.rows[i].cells[1].appendChild(input10);
var input1 = document.createElement("input");
input1.setAttribute("type","text");
input1.setAttribute("size","30");
input1.setAttribute("name","productName");
input1.setAttribute("disabled","true");
input1.setAttribute("id","productName"+j);
detailList.rows[i].cells[1].appendChild(input1);
var input8 = document.createElement("input");
input8.setAttribute("type","button");
input8.setAttribute("value","选择商品");
input8.onclick= selectProduct;
detailList.rows[i].cells[1].appendChild(input8);
detailList.rows[i].insertCell(2);
var input20 = document.createElement("input");
input20.setAttribute("type","hidden");
input20.setAttribute("name","shelfId");
input20.setAttribute("id","shelfId"+j);
detailList.rows[i].cells[2].appendChild(input20);
var input2 = document.createElement("input");
input2.setAttribute("type","text");
input2.setAttribute("size","25");
input2.setAttribute("name","shelfName");
input2.setAttribute("disabled","true");
input2.setAttribute("id","shelfName"+j);
detailList.rows[i].cells[2].appendChild(input2);
var input9 = document.createElement("input");
input9.setAttribute("type","button");
input9.setAttribute("value","选择货架");
input9.onclick= selectShelf;
detailList.rows[i].cells[2].appendChild(input9);
detailList.rows[i].insertCell(3);
var input3 = document.createElement("input");
input3.setAttribute("type","text");
input3.setAttribute("size","26");
input3.setAttribute("name","qty");
detailList.rows[i].cells[3].appendChild(input3);
detailList.rows[i].insertCell(4);
detailList.rows[i].cells[0].setAttribute("height","25");
var deleteRow = document.createElement("a");
deleteRow.setAttribute("href","javascript:deleteItem("+j+")");
deleteRow.appendChild(document.createTextNode("删除"));
detailList.rows[i].cells[4].appendChild(deleteRow); 展开
function addItem(){
var detailList = document.getElementById("detailList");
var i=detailList.rows.length;
var row = detailList.insertRow(i);
var rowIndex = detailList.rows[i].rowIndex;
var j=k;
detailList.rows[i].setAttribute("align","center");
detailList.rows[i].setAttribute("bgcolor","#FFFFFF");
detailList.rows[i].setAttribute("id","tr"+j);
detailList.rows[i].insertCell(0);
var text = document.createTextNode(rowIndex-1);
detailList.rows[i].cells[0].appendChild(text);
detailList.rows[i].insertCell(1);
var input10 = document.createElement("input");
input10.setAttribute("type","hidden");
input10.setAttribute("name","productId");
input10.setAttribute("id","productId"+j);
detailList.rows[i].cells[1].appendChild(input10);
var input1 = document.createElement("input");
input1.setAttribute("type","text");
input1.setAttribute("size","30");
input1.setAttribute("name","productName");
input1.setAttribute("disabled","true");
input1.setAttribute("id","productName"+j);
detailList.rows[i].cells[1].appendChild(input1);
var input8 = document.createElement("input");
input8.setAttribute("type","button");
input8.setAttribute("value","选择商品");
input8.onclick= selectProduct;
detailList.rows[i].cells[1].appendChild(input8);
detailList.rows[i].insertCell(2);
var input20 = document.createElement("input");
input20.setAttribute("type","hidden");
input20.setAttribute("name","shelfId");
input20.setAttribute("id","shelfId"+j);
detailList.rows[i].cells[2].appendChild(input20);
var input2 = document.createElement("input");
input2.setAttribute("type","text");
input2.setAttribute("size","25");
input2.setAttribute("name","shelfName");
input2.setAttribute("disabled","true");
input2.setAttribute("id","shelfName"+j);
detailList.rows[i].cells[2].appendChild(input2);
var input9 = document.createElement("input");
input9.setAttribute("type","button");
input9.setAttribute("value","选择货架");
input9.onclick= selectShelf;
detailList.rows[i].cells[2].appendChild(input9);
detailList.rows[i].insertCell(3);
var input3 = document.createElement("input");
input3.setAttribute("type","text");
input3.setAttribute("size","26");
input3.setAttribute("name","qty");
detailList.rows[i].cells[3].appendChild(input3);
detailList.rows[i].insertCell(4);
detailList.rows[i].cells[0].setAttribute("height","25");
var deleteRow = document.createElement("a");
deleteRow.setAttribute("href","javascript:deleteItem("+j+")");
deleteRow.appendChild(document.createTextNode("删除"));
detailList.rows[i].cells[4].appendChild(deleteRow); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询