Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
how should I code this ?
Old 12-26-2010, 06:58 PM how should I code this ?
Average Talker

Posts: 17
Name: charlie
Trades: 0
I'm having trouble with javascript - help please? this doesn't work.

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;
}
}
ckdoublenecks is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-26-2010, 07:00 PM Re: how should I code this ?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
And:

What is it supposed to?

What does it do? (or not)

What is/are the error(s)?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to how should I code this ?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45280 seconds with 12 queries