我在这里是新手,希望您能帮助我...所以我构建了一个库存应用程序。
有一个Mongo DB表包含产品,每种产品都必须拥有数量和最小的产品。
IM试图在可用数量少于产品的细微量时尝试创建过滤器,它将仅显示桌上的产品。
iv'e添加了两个警报,只是为了测试为什么循环在桌上的第一个产品上堆叠而不是继续以下产品。我希望我提供了足够的信息,谢谢
if (category == "Missing") {
document.querySelectorAll("tbody tr").forEach((element) => {
alert(Number(document.getElementById("prodMinQuantity").innerText));
alert(Number(document.getElementById("prodQuantity").innerText));
if (
Number(document.getElementById("prodMinQuantity").innerText) >
Number(document.getElementById("prodQuantity").innerText)
) {
alert("fgfgfg");
element.style.display = "none";
}
});
}
im new here and i hope you can help me... so im building an inventory app.
there is a mongo db table contains products and every product have quantity and MinQuantity it must have.
im trying to create a filter when there is less available quantity than the minQuantity of the product it will show only there products in the table.
iv'e added two alerts just to test why the loop is stack on the first product in the table and not moving on to the following products..I hope i gave enough information, thanks
if (category == "Missing") {
document.querySelectorAll("tbody tr").forEach((element) => {
alert(Number(document.getElementById("prodMinQuantity").innerText));
alert(Number(document.getElementById("prodQuantity").innerText));
if (
Number(document.getElementById("prodMinQuantity").innerText) >
Number(document.getElementById("prodQuantity").innerText)
) {
alert("fgfgfg");
element.style.display = "none";
}
});
}
发布评论
评论(1)
如果每行包含一个具有IDS
id 属性属性必须在文档中是唯一的。
prodminquantity
和prodquantity
的表,则应该更改该列,因为在html最好使用改为存储其他信息。
如果您坚持使用
ID
属性,则可以使用document.queryselector()
而不是:If you have a table where each row contains columns with ids
prodMinQuantity
andprodQuantity
, you should change that, because in HTMLid
attribute must be unique in the document.It's better to use
element.dataset
to store additional information instead.If you insist on using
id
attribute, then you can usedocument.querySelector()
instead: