Post Reply  Post Thread 
I could use help with javascript
Author Message
ckdoublenecks
Junior Member
**


Posts: 8
Group: Registered
Joined: Oct 2008
Status: Offline
Post: #1
I could use help with javascript

Martin, if you have the time to look, this code nothing beyond the datepaid and late. what is wrong with it?

Code:
<html><head>
<script>
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid(v) {
   var amtpaid = document.getElementById("amtpaid");
   var rentdue = document.getElementById("rentdue");
var prevbal = document.getElementById("prevbal");
var secdep = document.getElementById("secdep");
var latechg = document.getElementById("latechg");
var damage = document.getElementById("damage");
var courtcost = document.getElementById("courtcost");
var nsf = document.getElementById("nsf");
var tentpay = document.getElementById("tentpay");
var hudpay = document.getElementById("hudpay");
var datepaid = document.getElementById("datepaid");
var late = document.getElementById("late");
var paidsum = document.getElementById("paidsum");
  var dateNow = new Date();
  var dayNow = dateNow.getDate();
  var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
datepaid.value = datePaid;  
parseInt(amtpaid.value);
parseInt(rentdue.value);
parseInt(prevbal.value);
parseInt(secdep.value);
parseInt(latechg.value);
parseInt(damage.value);
parseInt(courtcost.value);
parseInt(nsf.value);
parseInt(tentpay.value);
parseInt(hudpay.value);
parseInt(paidsum.value);
var sumpaid;
var hold;
var totOwed = rentdue.value + prevbal.value + secdep.value + damage.value + latechg.value + courtcost.value + nsf.value - hudpay.value;
paidsum = paidsum.value + amtpaid.value;
if(dayNow > 5) { late.value = "L"; totOwed = totOwed + 10; }
switch(v)
{
case 1:
if (amtpaid.value >= totOwed.value) { prevbal.value = 0; secdep.value = 0;
damage.value = 0; latechg.value = 0; courtcost.value = 0; nsf.value = 0;}
break;
case 2:
var stillOwed = totOwed - amtpaid.value;
stillOwed = stillOwed - prevbal.value;
stillOwed = hold;
if (hold >= 0) { prevbal.value = 0;}
prevbal.value = prevbal.value + hold;
stillOwed = stillOwed - secdep.value;
stillOwed = hold;
if (hold >= 0) { secdep.value = 0;}
secdep.value = secdep.value + hold;
stillOwed = stillOwed - damage.value;
stillOwed = hold;
if (hold >= 0) { damage.value = 0;}
damage.value = damage.value + hold;
stillOwed = stillOwed - latechg.value;
stillOwed = hold;
if (hold >= 0) { latechg.value = 0;}
latechg.value = latechg.value + hold;
stillOwed = stillOwed - courtcost.value;
stillOwed = hold;
if (hold >= 0) { courtcost.value = 0;}
courtcost.value = courtcost.value + hold;
stillOwed = stillOwed - nsf.value;
stillOwed = hold;
if (hold >= 0) { nsf.value = 0;}
nsf.value = nsf.value + hold;
break;
}
}

12-26-2010 05:27 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: