Jump to content

calculator


NickG21

Recommended Posts

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.