私のためにテーブルを生成しているjavascriptがあります。テーブル内の要素は、sepと呼ばれる配列の配列に集められます。javascriptを使用してhtmlテーブルのアイテムごとの価格を生成
Sep[0] //["316SS", "K", "-100 to 225°C", "Brass", "1/8", "4'", "4'", "8", "Ungrounded"]
したがって、基本的に9つのパラメータで製品を定義し、それぞれが1152行が存在する:9月の形式のもので1152個のサブ配列が含まれています。私はそれぞれの構成の価格を作成するfor-loopを作りたいと思います。これは私がこれまで持っているものです。
//PART 1-------------WORKS FINE-----------------------------------
var eopartprice2 = []; //matrix that I want to contain my prices
for (var i = 0; i < sep.length; i++) {
strnum1 = sep[i][5]; //parameter 5 is a length of material
len1 = Number(strnum1.substr(0, strnum1.length - 1));
strnum2 = sep[i][6]; //parameter 6 is another length of material
len2 = Number(strnum2.substr(0, strnum2.length - 1));
strnum3 = sep[i][7]; //parameter 7 is the number of units required
condnum = Number(strnum3.substr(0, strnum3.length));
feetOfMat = len1*len2*condnum; //The product of these is the total feet of req material
//PART 2------------PFCost always = 0.87--------------------------
//Next i need to identify the cost of the material (to multiply by the total feet)
var costOfMat = [0.87, 0.87, 1.77, 0.55] //different costs of the 4 materials
if (sep[i][0] = "304SS") {
var PFCost = costOfMat[0]; //304SS costs 0.87/foot
} else if (sep[i][0] = "316SS") {
var PFCost = costOfMat[1]; //316SS costs 0.87/foot
} else if (sep[i][0] = "Inconel") {
var PFCost = costOfMat[2]; //Inconel costs 1.77/foot
} else if (sep[i][0] = "High Temp. Glass") {
var PFCost = costOfMat[3]; //High Temp. Glass costs 0.55/foot
}
baseMatCost[i] = PFCost*feetOfMat; //I'd like to generate a matrix that
//contains all of the base prices (1 for each row)
//PART 3---------------fitcost always = 36------------------------
//Trying to identify the cost of brass vs. stainless fittings
if (sep[i][3] = "Brass") {
fitcost = 36;
} else if (sep[i][3] = "Stainless Steel") {
fitcost = 37;
}
}
私の問題は、これまでのところ、私は価格がのオフに基づいて定義することにしたいということであるかどうかの文が成立しているが、場合、両方のケース(fitcostとPFCost)の値では、最初のif文で定義されたものに過ぎません。
最後に、上記で生成したマテリアルと労働コストの一部をマージンで掛け合わせたものに基づいて、eopartprice2マトリックスの最終価格を生成したいとします。
また、私はウェブサイトのライブテーブルになるので、これがどのくらい速く実行されるかに関心があります。これをさらに追加するたびに、生成に時間がかかります。ここで私はで働いている私のW3にlinkです。
、任意の助けをいただければ幸いしてください:)