javascript - How can I fix this array table? -
i have written simple array table using 3 values defined user. these 3 values determine value of variable. have written similar code before reason can not figure out why 1 not working. table large sorry size...
var ssridgeqty=document.getelementbyid("ssridgetrim").value; var ssridgewidth=document.getelementbyid("ssridgewidth").value; var ssridgecolorup; if (sscolorchoice=="galvalume") { ssridgecolorup="1"; } else if (sscolorchoice=="dark gray" || sscolorchoice=="antique bronze" || sscolorchoice=="rural red" || sscolorchoice=="dark green" || sscolorchoice=="fern green") { ssridgecolorup="2"; } else if (sscolorchoice=="metallic copper") { ssridgecolorup="3"; } else if (sscolorchoice=="none" && ssridgeqty>0) { ssridgecolorup=0; alert ("please choose ss color"); } else { ssridgecolorup="4"; } var ssridgecap = new array(); //retail, galvalume ssridgecap [[0],[1],[14]] = 21.75; ssridgecap [[0],[1],[16]] = 28.1; ssridgecap [[0],[1],[18]] = 31.3; ssridgecap [[0],[1],[20]] = 34.5; ssridgecap [[0],[1],[22]] = 37.7; ssridgecap [[0],[1],[24]] = 40.9; ssridgecap [[0],[1],[26]] = 44.1; ssridgecap [[0],[1],[28]] = 47.3; ssridgecap [[0],[1],[30]] = 50.5; ssridgecap [[0],[1],[32]] = 53.7; ssridgecap [[0],[1],[34]] = 56.9; ssridgecap [[0],[1],[36]] = 60.1; ssridgecap [[0],[1],[38]] = 63.3; ssridgecap [[0],[1],[40]] = 66.5; //retail, kynar ssridgecap [[0],[2],[14]] = 25.85; ssridgecap [[0],[2],[16]] = 31.3; ssridgecap [[0],[2],[18]] = 34.9; ssridgecap [[0],[2],[20]] = 38.5; ssridgecap [[0],[2],[22]] = 42.1; ssridgecap [[0],[2],[24]] = 45.7; ssridgecap [[0],[2],[26]] = 49.3; ssridgecap [[0],[2],[28]] = 52.9; ssridgecap [[0],[2],[30]] = 56.5; ssridgecap [[0],[2],[32]] = 60.1; ssridgecap [[0],[2],[34]] = 63.7; ssridgecap [[0],[2],[36]] = 67.3; ssridgecap [[0],[2],[38]] = 70.9; ssridgecap [[0],[2],[40]] = 74.5; //retail, metallic copper ssridgecap [[0],[3],[14]] = 26.55; ssridgecap [[0],[3],[16]] = 35.3; ssridgecap [[0],[3],[18]] = 39.4; ssridgecap [[0],[3],[20]] = 43.5; ssridgecap [[0],[3],[22]] = 47.6; ssridgecap [[0],[3],[24]] = 51.7; ssridgecap [[0],[3],[26]] = 55.8; ssridgecap [[0],[3],[28]] = 59.9; ssridgecap [[0],[3],[30]] = 64; ssridgecap [[0],[3],[32]] = 68.1; ssridgecap [[0],[3],[34]] = 72.2; ssridgecap [[0],[3],[36]] = 76.3; ssridgecap [[0],[3],[38]] = 80.4; ssridgecap [[0],[3],[40]] = 84.5; //retail, syl-poly ssridgecap [[0],[4],[14]] = 22.5; ssridgecap [[0],[4],[16]] = 28.9; ssridgecap [[0],[4],[18]] = 32.2; ssridgecap [[0],[4],[20]] = 35.5; ssridgecap [[0],[4],[22]] = 38.8; ssridgecap [[0],[4],[24]] = 42.1; ssridgecap [[0],[4],[26]] = 45.4; ssridgecap [[0],[4],[28]] = 48.7; ssridgecap [[0],[4],[30]] = 52; ssridgecap [[0],[4],[32]] = 55.3; ssridgecap [[0],[4],[34]] = 58.6; ssridgecap [[0],[4],[36]] = 61.9; ssridgecap [[0],[4],[38]] = 65.2; ssridgecap [[0],[4],[40]] = 68.5; //contractor, galvalume ssridgecap [[1],[1],[14]] = 20.38; ssridgecap [[1],[1],[16]] = 26.5; ssridgecap [[1],[1],[18]] = 29.5; ssridgecap [[1],[1],[20]] = 32.5; ssridgecap [[1],[1],[22]] = 35.5; ssridgecap [[1],[1],[24]] = 38.5; ssridgecap [[1],[1],[26]] = 41.5; ssridgecap [[1],[1],[28]] = 44.5; ssridgecap [[1],[1],[30]] = 47.5; ssridgecap [[1],[1],[32]] = 50.5; ssridgecap [[1],[1],[34]] = 53.5; ssridgecap [[1],[1],[36]] = 56.5; ssridgecap [[1],[1],[38]] = 59.5; ssridgecap [[1],[1],[40]] = 62.5; //contractor, kynar ssridgecap [[1],[2],[14]] = 25.2; ssridgecap [[1],[2],[16]] = 30.5; ssridgecap [[1],[2],[18]] = 34; ssridgecap [[1],[2],[20]] = 37.5; ssridgecap [[1],[2],[22]] = 41; ssridgecap [[1],[2],[24]] = 44.5; ssridgecap [[1],[2],[26]] = 48; ssridgecap [[1],[2],[28]] = 51.5; ssridgecap [[1],[2],[30]] = 55; ssridgecap [[1],[2],[32]] = 58.5; ssridgecap [[1],[2],[34]] = 62; ssridgecap [[1],[2],[36]] = 65.5; ssridgecap [[1],[2],[38]] = 69; ssridgecap [[1],[2],[40]] = 72.5; //contractor, meta1llic copper ssridgecap [[1],[3],[14]] = 25.85; ssridgecap [[1],[3],[16]] = 34.5; ssridgecap [[1],[3],[18]] = 38.5; ssridgecap [[1],[3],[20]] = 42.5; ssridgecap [[1],[3],[22]] = 46.5; ssridgecap [[1],[3],[24]] = 50.5; ssridgecap [[1],[3],[26]] = 54.5; ssridgecap [[1],[3],[28]] = 58.5; ssridgecap [[1],[3],[30]] = 62.5; ssridgecap [[1],[3],[32]] = 66.5; ssridgecap [[1],[3],[34]] = 70.5; ssridgecap [[1],[3],[36]] = 74.5; ssridgecap [[1],[3],[38]] = 78.5; ssridgecap [[1],[3],[40]] = 82.5; //contractor, syl-poly ssridgecap [[1],[4],[14]] = 21.75; ssridgecap [[1],[4],[16]] = 28.1; ssridgecap [[1],[4],[18]] = 31.3; ssridgecap [[1],[4],[20]] = 34.5; ssridgecap [[1],[4],[22]] = 37.7; ssridgecap [[1],[4],[24]] = 40.9; ssridgecap [[1],[4],[26]] = 44.1; ssridgecap [[1],[4],[28]] = 47.3; ssridgecap [[1],[4],[30]] = 50.5; ssridgecap [[1],[4],[32]] = 53.7; ssridgecap [[1],[4],[34]] = 56.9; ssridgecap [[1],[4],[36]] = 60.1; ssridgecap [[1],[4],[38]] = 63.3; ssridgecap [[1],[4],[40]] = 66.5; //wholesale, galvalume ssridgecap [[2],[1],[14]] = 19; ssridgecap [[2],[1],[16]] = 24.9; ssridgecap [[2],[1],[18]] = 27.7; ssridgecap [[2],[1],[20]] = 30.5; ssridgecap [[2],[1],[22]] = 33.3; ssridgecap [[2],[1],[24]] = 36.1; ssridgecap [[2],[1],[26]] = 38.9; ssridgecap [[2],[1],[28]] = 41.7; ssridgecap [[2],[1],[30]] = 44.5; ssridgecap [[2],[1],[32]] = 47.3; ssridgecap [[2],[1],[34]] = 50.1; ssridgecap [[2],[1],[36]] = 52.9; ssridgecap [[2],[1],[38]] = 55.7; ssridgecap [[2],[1],[40]] = 58.5; //wholesale, kynar ssridgecap [[2],[2],[14]] = 22.48; ssridgecap [[2],[2],[16]] = 26.5; ssridgecap [[2],[2],[18]] = 29.5; ssridgecap [[2],[2],[20]] = 32.5; ssridgecap [[2],[2],[22]] = 35.5; ssridgecap [[2],[2],[24]] = 38.5; ssridgecap [[2],[2],[26]] = 41.5; ssridgecap [[2],[2],[28]] = 44.5; ssridgecap [[2],[2],[30]] = 47.5; ssridgecap [[2],[2],[32]] = 50.5; ssridgecap [[2],[2],[34]] = 53.5; ssridgecap [[2],[2],[36]] = 56.5; ssridgecap [[2],[2],[38]] = 59.5; ssridgecap [[2],[2],[40]] = 62.5; //wholesale, meta1llic copper ssridgecap [[2],[3],[14]] = 23.15; ssridgecap [[2],[3],[16]] = 30.5; ssridgecap [[2],[3],[18]] = 34; ssridgecap [[2],[3],[20]] = 37.5; ssridgecap [[2],[3],[22]] = 41; ssridgecap [[2],[3],[24]] = 44.5; ssridgecap [[2],[3],[26]] = 48; ssridgecap [[2],[3],[28]] = 51.5; ssridgecap [[2],[3],[30]] = 55; ssridgecap [[2],[3],[32]] = 58.5; ssridgecap [[2],[3],[34]] = 62; ssridgecap [[2],[3],[36]] = 65.5; ssridgecap [[2],[3],[38]] = 69; ssridgecap [[2],[3],[40]] = 72.5; //wholesale, syl-poly ssridgecap [[2],[4],[14]] = 19.1; ssridgecap [[2],[4],[16]] = 26.5; ssridgecap [[2],[4],[18]] = 29.5; ssridgecap [[2],[4],[20]] = 32.5; ssridgecap [[2],[4],[22]] = 35.5; ssridgecap [[2],[4],[24]] = 38.5; ssridgecap [[2],[4],[26]] = 41.5; ssridgecap [[2],[4],[28]] = 44.5; ssridgecap [[2],[4],[30]] = 47.5; ssridgecap [[2],[4],[32]] = 50.5; ssridgecap [[2],[4],[34]] = 53.5; ssridgecap [[2],[4],[36]] = 56.5; ssridgecap [[2],[4],[38]] = 59.5; ssridgecap [[2],[4],[40]] = 62.5; var ssridgeprice = ssridgecap [[pricelevel],[ssridgecolorup],[ssridgewidth]]; document.getelementbyid("ssridgetest4").innerhtml=ssridgeprice;
the result coming last set of arrays labeled wholesale syl-pol. if change width value changes if change price level or color (the first 2 [] in array, nothing changes. reason these values stuck on [2] , [4].
if need other reference ask , post it. need urgent
(ps. price level set radio button labled 1, 2, 3, when test print out 3 deciding variables "pricelevel", "ssridgecolorup", , ssridgewidth, come correctly array not picking them up?
thank in advance time.
another solution use multi-dimensional array
var ssridgecap = new array(); ssridgecap[0] = []; ssridgecap[0][1] = []; ssridgecap[0][1][14]= 21.75;
then can access using
ssridgecap[0][1][14]
Comments
Post a Comment