Jump to content

JavaScript Calculator


EriX

Recommended Posts

Hello,

 

I got problem, with JavaScript i really don't work,but now i need some script.

 

So, i need to calculate 3 different values.

Weight - size - Total Cost

 

I use 2 different function to calculate theses values, but now i don't understand how i need to calculate last value - Total cost.

Formula is:

if((info_from_mysql < weight) or info_from_mysql < size)

{

    Total Cost = Info_from_mysql_table;

}

 

 

So maybe someone has any mind how to do it?

 

 

By the way i use this function to calculate weight and size:

 

function UpdateWeight() {
  var sum = 0;
  var gn, elem;
  for (i=0; i<7; i++) {
    gn = 'order'+i;
    elem = document.getElementById(gn);
    if (elem.checked == true) { sum += Number(elem.value); }
  }
  document.getElementById('weight').value = sum.toFixed(2);
}

 

 

Thanks for help.

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.