Hello all.
I am new to Java Scripting, but I have been handed a previous employees job. My task is to create a calculator and having had little or no experience doing this I am asking for any help resolve my problem. The problem is that I used the calculator that was already in place and made the modifications to that one and it works to a certain excelpt for the last statment at the bottom (see below). I have been staring for hrs like creator said no help Can anyone please help?
function load()
{
}
function count()
{
var elprice = 4.49;// look at description of calculate_hs.js for details about prices…
var igprice = 3.99; // The code is a pain.. i wrote if statements for an automatic discount of 1$ each 2 products
var egprice = 4.49; // Just stare for a while and you will figure it out
var esprice = 5.99;
var ewprice = 4.99;
var ilprice = 2.49;
var coolprice = 9.99;
var heatprice = 9.99;
var heatpump = 17.99;
var whprice = 4.99;
if (calc.el.checked){
var wel = document.calc.el.value = elprice;
} else {
var wel = document.calc.el.value = 0;
}
if (calc.ig.checked){
var wig = document.calc.ig.value = igprice;
} else {
var wig = document.calc.ig.value = 0;
}
if (calc.eg.checked) {
var weg = document.calc.eg.value = egprice;
} else {
var weg = document.calc.eg.value = 0;
}
if (calc.ew.checked) {
var wew = document.calc.ew.value = ewprice;
} else {
var wew = document.calc.ew.value = 0;
}
if (calc.es.checked) {
var wes = document.calc.es.value = esprice;
} else {
var wes = document.calc.es.value = 0;
}
if (calc.il.checked) {
var wil = document.calc.il.value = ilprice;
} else {
var wil = document.calc.il.value = 0;
}
if (calc.cool.checked) {
var wcool = document.calc.cool.value = coolprice;
} else {
var wcool = document.calc.cool.value = 0;
}
if (calc.heat.checked) {
var wheat = document.calc.heat.value = heatprice;
} else {
var wheat = document.calc.heat.value = 0;
}
if (calc.heatpump.checked) {
var wheatpump = document.calc.heatpump.value = heatpump;
} else {
var wheatpump = document.calc.heatpump.value = 0;
}
if (calc.wh.checked) {
var wwh = document.calc.wh.value = whprice;
} else {
var wwh = document.calc.wh.value = 0;
}
if (calc.el.checked){
var del = document.calc.el.value = 1; //code for discounts
} else {
var del = document.calc.el.value = 0;
}
if (calc.ig.checked){
var dig = document.calc.ig.value = 1;
} else {
var dig = document.calc.ig.value = 0;
}
if (calc.eg.checked) {
var deg = document.calc.eg.value = 1;
} else {
var deg = document.calc.eg.value = 0;
}
if (calc.ew.checked) {
var dew = document.calc.ew.value = 1;
} else {
var dew = document.calc.ew.value = 0;
}
if (calc.es.checked) {
var des = document.calc.es.value = 1;
} else {
var des = document.calc.es.value = 0;
}
if (del + dig + deg + dew + des <= 1){
var discount = 0;
} else {
var discount = del + dig + deg + dew + des – 1;
}
if (wwh + wheatpump >18){
var discount2 = 1;
} else {
var discount2 = 0;
}
document.calc.pay.value = wel + wig + weg + wew + wes + wil +
wcool + wheat + wheatpump + wwh – discount-discount2;
}