Hello everyone.
I have a form that I have developed and am stuck. The outputs that are displayed should be in 2 decimal places. I have searched for ways to do this, but to no avail have they worked for my piece of code. Please have a look and if you could, suggest a way of making this output work for me as needed. :confused:
The form is used to calculate savings and is working as expected (giving me the correct results from the calculated inputs), but only fully after clicking 4 times. I guess this is because the form needs the previous outputs to go ahead with the next calculation, could you also suggest a method that the calculation could loop and complete all calculations with only one click? I'm sure there is a way, I just have no clue how to.
Code
JavaScript
Code:
function showpay() {
if ((document.calc.a.value == null || document.calc.a.value.length == 0) ||
(document.calc.b.value == null || document.calc.b.length == 0) ||
(document.calc.c.value == null || document.calc.c.value.length == 0) ||
(document.calc.d.value == null || document.calc.d.value.length == 0) ||
(document.calc.e.value == null || document.calc.e.value.length == 0))
{ alert("Please enter all values");
}
else
{
var aa = document.calc.a.value;
var ab = document.calc.b.value;
var ac = document.calc.c.value;
var ad = document.calc.d.value;
var ae = document.calc.e.value;
var af = document.calc.f.value;
var ag = document.calc.g.value;
var ah = document.calc.h.value;
var ai = document.calc.i.value;
var aj = document.calc.j.value;
var ak = document.calc.k.value;
var al = document.calc.l.value;
var am = document.calc.m.value;
var an = document.calc.n.value;
var ao = document.calc.o.value;
var ap = document.calc.p.value;
var aq = document.calc.q.value;
var ar = document.calc.r.value;
var as = document.calc.s.value;
var at = document.calc.t.value;
var au = document.calc.u.value;
var av = document.calc.v.value;
var aw = document.calc.w.value;
// calculations
document.calc.f.value = ab * ac;
document.calc.g.value = ac * ad;
document.calc.h.value = ae / ag;
document.calc.i.value = ah / 4.3;
document.calc.j.value = ai / 4.3;
document.calc.k.value = ai / 52;
document.calc.l.value = aa * 1;
document.calc.m.value = "$" + aa * af;
document.calc.n.value = ad * af;
document.calc.o.value = "$" + aa * ag;
document.calc.p.value = aa * 4.3;
document.calc.q.value = "$" + af * ap;
document.calc.r.value = ad * ap;
document.calc.s.value = "$" + ag * ap;
document.calc.t.value = ap * 12;
document.calc.u.value = "$" + af * at;
document.calc.v.value = ad * at;
document.calc.w.value = "$" + (ag * at);
}
}
HTML Output Excuse the tables please.
Code:
Enter your data in the white fields to work out cost savings <br /> of a Bioptics Specimen Radiography system, or test different scenarios by varying the inputs.
Costs
<strong>Surgeries Per Week </strong><br>
How many breast surgeries do you perform?
<strong>Average Minutes Per Surgery </strong>
<strong>Average Cost Per Surgery </strong>
<strong>Minutes Saved Per Surgery </strong>
How many minutes can you save per surgery if you
don't<br> have to send the specimen out for imaging?
<strong>Cost of Digital Equipment</strong>
List price quoted by Bioptics sales representative.
Results
<strong>Cost of Surgeries</strong>
<strong>Amount saved per surgery</strong>
<strong>Surgeries Until Investment is recovered</strong>
<strong>Time Until Investment is recovered</strong>
Weeks
Months
Years
Savings
<strong>Total Number<br />of Surgeries</strong>
<strong>Total Cost<br />of Surgeries</strong>
<strong>Total Minutes<br />Saved</strong>
<strong>Total Amount<br />Saved</strong>
<strong>Weekly</strong>
<strong>Monthly</strong>
<strong>Annually</strong>
<img src="images/print_btn_up.png" alt="" name="Pictures" width="100" height="33" align="top">
Please excuse the table. I have also attached an image of the output so you have a better idea.
Many thanks guys. Cheers,
DS</br></br></br></br></br></br></br></img>