Javascript function runs the first time but won't again -


context behind this, there function listens change in html dropdown. when there change, javascript calls costs function , puts in new variables, should recalculate cost.

however, after running first time, code not run again. know because alert "i running" appears when function called first time.

any idea overlooking?

function costs(f, p) {         window.alert("i running");         costs = [10500, 33950, 33950, 22576, 22576, 22576, 39324, 39324, 39324, 39324, 39324, 0];         models = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "\u00a0"];         ind = models.indexof(f);         = ((p/100)*costs[ind]).tofixed(2);         b = a.tostring().replace(/\b(?=(\d{3})+(?!\d))/g, ",");         c = "$"+b;         return c;     }; 

thanks!

you're redefining costs within function @ line:

costs = [10500, 33950, 33950, 22576, 22576, 22576, 39324, 39324, 39324, 39324, 39324, 0]; 

make different variable name.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

python - GitPython: check if git is available -

How to merge four videos on one screen with ffmpeg -