html table < /p>
У меня также есть небольшой массив из 4 предметов, заполняющих таблицу, следовательно, почему заселено 4 строки. Я упускаю что -то простое? (appreciate you may not know until seeing the code but may be something simple, i will attach more code snippets under this post)
I also am not sure what section of the code to attach to this post but here is what i have relating to the table style:
Код: Выделить всё
function addTableRow(ProductCode, ProductName, ProductTotal, Price, Offer, LCOffer){
if (!document.getElementsByTagName){
return;
}
var x = document.getElementById("inventoryTable").rows.length;
tableBody = document.getElementsByTagName("tbody").item(0);
row = document.createElement("tr");
row.id = x
ProductCodeC = document.createElement("td");
ProductNameC = document.createElement("td");
ProductTotalC = document.createElement("td");
PriceC = document.createElement("td");
OfferC = document.createElement("td");
LCOfferC = document.createElement("td");
ProductCodeC.width = "500px";
ProductCodeC.height = "500px";
ProductNameC.width = "500px";
ProductNameC.height = "500px";
ProductTotalC.width = "500px";
ProductTotalC.height = "500px";
PriceC.width = "500px";
PriceC.height = "500px";
OfferC.width = "500px";
OfferC.height = "500px";
LCOfferC.width = "500px";
LCOfferC.height = "500px";
ProductCodeTNode = document.createTextNode(ProductCode);
ProductNameTNode = document.createTextNode(ProductName);
ProductTotalTNode = document.createTextNode(ProductTotal);
PriceTNode = document.createTextNode(Price);
OfferTNode = document.createTextNode(Offer);
LCOfferTNode = document.createTextNode(LCOffer);
row.appendChild(ProductCodeC);
row.appendChild(ProductNameC);
row.appendChild(ProductTotalC);
row.appendChild(PriceC);
row.appendChild(OfferC);
row.appendChild(LCOfferC);
tableBody.appendChild(row);
console.log(ProductName);
console.log(ProductTotal)
}< /code>
table, th, td {
border: 2px solid white;
border-collapse: collapse;
color: black;
width:auto;
height:auto
}< /code>
Product Code
Product Name
Product Total
Price
Offer
Loyalty card Offer
Подробнее здесь: https://stackoverflow.com/questions/733 ... array-data
Мобильная версия