NickG21 Posted January 10, 2007 Share Posted January 10, 2007 hey everyone, i have a calculator that uses the user input in order to display for them the approximate cost of the services they want. the calculator works perfectly and does what it should, except that we are now implementing new prices and i was not involved in the original coding of this.here is the entire code if you are interested:[code]function dosum(){ <!-- set vars --!> var k_to_gig = 1000000; var cost_per_gig = 10; var bandwidth = 0; var priceBracket = new Array(); var priceList = new Array(); var newListSize = nocommas(document.form.Input_List_Size.value);var newEntListSize = nocommas(document.form.Input_List_Size.value);priceBracket.push(100);priceList.push(5);priceBracket.push(500);priceList.push(7.5);priceBracket.push(1000);priceList.push(10);priceBracket.push(2000);priceList.push(15);priceBracket.push(3000);priceList.push(20);priceBracket.push(4000);priceList.push(22.5);priceBracket.push(5000);priceList.push(25);priceBracket.push(7500);priceList.push(32.5);priceBracket.push(10000);priceList.push(37.5);priceBracket.push(15000);priceList.push(50);priceBracket.push(20000);priceList.push(60);priceBracket.push(30000);priceList.push(70);priceBracket.push(40000);priceList.push(90);priceBracket.push(50000);priceList.push(110);priceBracket.push(60000);priceList.push(125);priceBracket.push(80000);priceList.push(142.5);priceBracket.push(100000);priceList.push(180); <!-- Compute Cost For List Size --!> var x = 0;for(; newListSize > priceBracket[x]; x++);document.form.Comp_List_Cost.value = commas(priceList[x]);//alert(priceList[x]); <!-- Compute Total Bandwidth --!> bandwidth = newListSize * document.form.Input_Message_Size.value * document.form.Input_Posts_Month.value / k_to_gig; <!-- Compute Bandwidth Cost --!> if (bandwidth <= 1) document.form.Comp_Extra_traffic_Cost.value = 0; else document.form.Comp_Extra_traffic_Cost.value = commas((bandwidth-1) * cost_per_gig); <!-- Compute Cost Total List --!> document.form.Comp_Total_Cost_Pro.value = commas(nocommas(document.form.Comp_List_Cost_Pro.value)/1 + nocommas(document.form.Comp_Extra_traffic_Cost.value)/1); dosum2(); }function dosum2(){ document.form.Comp_List_Cost_Pro.value = commas(nocommas(document.form.Comp_List_Cost.value) * 2); document.form.Comp_List_Cost_Ent.value = commas(nocommas(document.form.Comp_List_Cost.value) * 3); document.form.Comp_Extra_traffic_Cost_Pro.value = document.form.Comp_Extra_traffic_Cost.value; document.form.Comp_Extra_traffic_Cost_Ent.value = document.form.Comp_Extra_traffic_Cost.value; document.form.Comp_Total_Cost_Pro.value = commas(nocommas(document.form.Comp_List_Cost_Pro.value)/1 + nocommas(document.form.Comp_Extra_traffic_Cost_Pro.value)/1) document.form.Comp_Total_Cost_Ent.value = commas(nocommas(document.form.Comp_List_Cost_Ent.value)/1 + nocommas(document.form.Comp_Extra_traffic_Cost_Ent.value)/1)}-->[/code]what i want to do is write an if statement that says if pricebracket <= 2000 than [code]commas(nocommas(document.form.Comp_List_Cost.value) * 3);[/code] equals 45 otherwise use that code. i hope this isn't rediculous to everyone, sorry if it is Quote Link to comment Share on other sites More sharing options...
fenway Posted January 10, 2007 Share Posted January 10, 2007 I'm not sure I understand. Quote Link to comment Share on other sites More sharing options...
NickG21 Posted January 10, 2007 Author Share Posted January 10, 2007 i just want to write a statement that saysif input.value <=2000 list_cost_pro.value calculates the same butlist_cost_ent.value = 45;then for anything greater than 2000, just follow the rules already in place Quote Link to comment Share on other sites More sharing options...
fenway Posted January 10, 2007 Share Posted January 10, 2007 You mean like this?[code]if( input.value <= 2000 ) list_cost_ent.value = 45;[/code] Quote Link to comment Share on other sites More sharing options...
NickG21 Posted January 11, 2007 Author Share Posted January 11, 2007 yes that is what i mean but i tried writing that exact statement and i wasn't sure where to implement it, and i do not think it will work to just throw it in because of the dosum2(); function, and because both values are affected by the same input. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 11, 2007 Share Posted January 11, 2007 Well, you're changing the actual INPUT values, or so it seems, so as long as you do this before you start playing around, you'll be fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.