Hello,

Thank you in advance for any help you can provide me. I am trying to write a simple formula to figure a few simple equations. I have very little programing experience and basically have no idea waht I am doing. With the script below I am trying to add an if else command but don't know where it would go. Bassically I want field ProgressiveTotal to to reply a message if the total formula exceeds the amount of field ApprovedLease. I think it should read something like

if (Reciept - Service - Other - Buydown)
{
ProgressiveTotal="Reciept - Service - Other - Buydown)<ApprovedLease";
}
else
{
ProgressiveTotal="Additional Lease Buydown Required";
}


I just can't figure out where to put it.

Also I would like all result fields to Round 2 decimal places but can't figure where to put the math.round command. Please if you have any suggestions I would appriceate the help.


<!DOCTYPE html>
Approved Lease Amount: <input id="ApprovedLease" type="number" value="300.00"/>
<br/>
Total POS Reciept: <input id="Reciept" type="number" value="500.00"/>
<br/>
1St Month Service: <input id="Service" type="number" value="50.00"/>
<br/>
Other Non-Tangible Items: <input id="Other" type="number" value="15.00"/>
<br/>
Additional Lease Buydown: <input id="Buydown" type="number" value="25.00"/>
<br/><br/><br/><br/>


Minimum Down Payment On Lease: <strong id="LeaseStartup"></strong>
<br/>
Tender1: <strong id="Tender1"></strong>
<br/>
Tender2: <strong id="Tender2"></strong>
<br/>
ProgressiveTotal: <strong id="ProgressiveTotal"></strong>

<script>
function result(ApprovedLease, Reciept, Service, Other, Buydown) {
var data = [{ }];
var LeaseStartup = (Reciept - Service - Other - Buydown) * .10
var Tender1 = LeaseStartup + Service + Other + Buydown
var Tender2 = Reciept-((Reciept - Service - Other - Buydown) * .10)
var ProgressiveTotal = (Reciept - Service - Other - Buydown)

return {
LeaseStartup: LeaseStartup,
Tender1: Tender1,
Tender2: Tender2,
ProgressiveTotal: ProgressiveTotal,
};
}

var ApprovedLease = document.getElementById('ApprovedLease');
var Reciept = document.getElementById('Reciept');
var Service = document.getElementById('Service');
var Other = document.getElementById('Other');
var Buydown = document.getElementById('Buydown');


function update() {
var res = result(Number(ApprovedLease.value), Number(Reciept.value), Number(Service.value), Number(Other.value), Number(Buydown.value));
LeaseStartup.innerHTML = res.LeaseStartup;
Tender1.innerHTML = res.Tender1;
Tender2.innerHTML = res.Tender2;
ProgressiveTotal.innerHTML = res.ProgressiveTotal;


}

ApprovedLease.onchange = update;
Reciept.onchange = update;
Service.onchange = update;
Other.onchange = update;
Buydown.onchange = update;

update();
</script>