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
https://forums.phpfreaks.com/topic/233503-javascript-calculator/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.