Javascript: calculating remaining time (and then rent) on a tenancy (Rent Calculator) -
i work @ corporate estate agency , i'm creating internal page staff use contain few small tools them use among other things. one of things i've been trying put rent calculator, which, given rental amount , lease expiry date user, needs determine time left (from today) on lease , advise how rent left pay on lease. i've got working, mostly, can see it's long (i'm assuming extent has be) , feel reasonably messy: //calculates remaining rent left pay terminated leases $("input[name='calcrent']").click(function() { //gets rent , daily rent later calculations var rent = $("input[name='rentrent']").val(); var dailyrate = (rent * 12) / 365; var leaseexpiry = $("input[name='leaseexpiry']").val(); var remrent = $("input[name='remrent']"); //breaks down lease expiry date , today's date day, month, year parts //so units can used in calculations var ldd = leaseexp...