// // There are 2 files that need to be updated to keep the calculator up to date: // This file (PropCalc.js), and the file called PropCalc . There are comments // in both files describing exactly what needs to be changed. // // NOTE - For the Town of Derry, there are only 2 variables in here that need to be updated. Scroll // down just a little and you will see 2 variables highlighted in RED. These are the only 2 values that // apply to how Derry is using this file. The rest of the variables and code are not being used here // and do not need to be updated at all. // // Be sure to adhere to the same format -- for totaltownvaluation simply change the value inside the // quotes, and for taxrate all you need to do is replace the number that is there. The semi-colons and // quotes in these variable declarations are important - please do not remove them. Thank you. // // // // Important Note - something to watch when you're editing code in here -- the first thing the page does // when its done loading is to populate all the constant values - tax rates, town valuation, and all the // department numbers in the 3rd table. If you've made an error in coding when editing stuff here, // there is a decent change it will affect the whole file, including the setupPage function. So, after // you've made your changes, saved this file, and refreshed your browser window, one huge hint that there // is a coding error is if the page does not automatically fill in these values. // // Note -- Naming convention: there will be a 1, 2, or 3 after (on in) the id name to indicate which table // it belongs to. For example, townrate2 is the field containing the town's tax rate value in table #2 // // For the 3rd table, its a little more involved -- admin3total is the total Administration value for the 3rd // table (this comes from the list below and populates the 2nd column in table #3), while admin3portion is // the taxpayer's portion of that total amount (this is the results of all the calculations we're doing here // and populates the fields in the 3rd column of table #3). All the subcategories in the 3rd table are named // the same way. // // Warning - if you're making changes to any of the calculations or other code - remember that this stuff is // *very* picky and it *is* case sensitive with everything - variable names, function calls, etc. // // When the page has finished loading, run the setupPage function, which fills in the constant values // from the list below. window.onload = setupPage; // // Define the page-wide rates here. When they change for another year, all that needs to be // done is to adjust the values in the list just below here and the whole page will update // automatically. // var totaltownvaluation = "To Be Supplied"; // this is a string variable - we don't use it for any calculations // so its a quoted string because it looks better with the commas // // Try to *not* change any of the names of these variables - they're used in various places in the other functions // and you'll need to be careful to change every reference to make a change work for you. // var taxrate = 16.29; var countytaxrate = 3.46; var towntaxrate = 3.14; var schooltaxrate = 5.60; var Administration = 279873; var Selectmen = 15300; var TownManager = 54400; var ClerkTaxCollector = 77060; var CodeEnforcement = 52868; var HealthOfficer = 985; var GeneralAssistance = 21235; var Elections = 1785; var AppealsBoard = 1048; var PlanningBoard = 5036; var ServiceProviders = 13500; var Alarms = 3300; var AnimalControl = 5550; var Rescue = 52649; var DaytimeRescue = 6500; var Fire = 77790; var Dispatch = 11300; var SolidWaste = 134289; var HazardousWaste = 11000; var RWSDebtService = 3800; var Roads = 281976; var SnowRemoval = 204524; var StreetLights = 10000; var TownHall = 21167; var TownOffice = 16005; var TownGarage = 19547; var VeteransMemorial = 2100; var SebagoCemetery = 1025; var AssociatedCemeteries = 600; var SmallCemeteries = 75; var SebagoDays = 5000; var MemorialDay = 500; var RecreationAdministration = 21310; var DouglasMountain = 3300; var TownBeach = 4950; var SYAABaseball = 4500; var Soccer = 500; var Football = 500; var Basketball = 1500; var Library = 20000; var CIP = 329609; var CountyTax = 220517; var MSAD61 = 3232614; var TotalTownTax = 5231087; // // *** End of page-wide values *** // // // This function will take the number and clean it up so it looks like dollars and cents // function FixNum(num) { var z1 = (Math.round(num*100)/100) + ""; // round to the nearest hundredth and add "" to convert to string var locPeriod = z1.indexOf("."); // find location of "." in the number if (locPeriod == -1) // If there is no ".", then its an integer { z1 = "$" + z1 + ".00"; // so add the .00 at the end, and the "$" at the beginning return(z1); } else // otherwise there is a "." { var Len1 = z1.length; // how long is the string? var locat = Len1 - 3; // what is the location of the character 3rd from the end var char1 = z1.charAt(locat); // grab that character if (char1 != ".") // We already know its *not* an integer *and* its rounded to the z1 = z1 + "0"; // nearest hundredth, so if the 3rd character from the end is not z1 = "$" + z1; // a ".", then there is only a single digit after the ".", such return(z1); // as 52.7. So add the extra "0" at the end to make it look right; } // and put the "$" at the beginning } // // This function gets called when the user clicks on the Calculate button. It will call the calculateForm // function if the input is a valid number, otherwise it will give us a message box and reset the form. // function VerifyInput() { if (isNaN(property_calc.propvalue.value)) { alert(" Please input a valid number\n(with no punctuation or commas)"); resetForm(); } else { calculateForm(); } } // // This setupPage function call will take the values from the variable list above and populate the // page when it first loads. // function setupPage() { document.getElementById("townvalue1").innerHTML = totaltownvaluation; property_calc.propvalue.value = "0"; document.getElementById("rate1").innerHTML = FixNum(taxrate); document.getElementById("countyrate2").innerHTML = FixNum(countytaxrate); document.getElementById("townrate2").innerHTML = FixNum(towntaxrate); document.getElementById("schoolrate2").innerHTML = FixNum(schooltaxrate); document.getElementById("taxrate2").innerHTML = FixNum(taxrate); document.getElementById("propvalue3a").innerHTML = "0"; document.getElementById("propvalue3b").innerHTML = "0"; document.getElementById("propvalue3c").innerHTML = "0"; document.getElementById("admin3total").innerHTML = "$" + Administration; document.getElementById("select3total").innerHTML = "$" + Selectmen; document.getElementById("manager3total").innerHTML = "$" + TownManager; document.getElementById("clerk3total").innerHTML = "$" + ClerkTaxCollector; document.getElementById("code3total").innerHTML = "$" + CodeEnforcement; document.getElementById("health3total").innerHTML = "$" + HealthOfficer; document.getElementById("general3total").innerHTML = "$" + GeneralAssistance; document.getElementById("election3total").innerHTML = "$" + Elections; document.getElementById("appeals3total").innerHTML = "$" + AppealsBoard; document.getElementById("planning3total").innerHTML = "$" + PlanningBoard; document.getElementById("service3total").innerHTML = "$" + ServiceProviders; document.getElementById("alarms3total").innerHTML = "$" + Alarms; document.getElementById("animal3total").innerHTML = "$" + AnimalControl; document.getElementById("rescue3total").innerHTML = "$" + Rescue; document.getElementById("day3total").innerHTML = "$" + DaytimeRescue; document.getElementById("fire3total").innerHTML = "$" + Fire; document.getElementById("dispatch3total").innerHTML = "$" + Dispatch; document.getElementById("solid3total").innerHTML = "$" + SolidWaste; document.getElementById("hazard3total").innerHTML = "$" + HazardousWaste; document.getElementById("debt3total").innerHTML = "$" + RWSDebtService; document.getElementById("roads3total").innerHTML = "$" + Roads; document.getElementById("snow3total").innerHTML = "$" + SnowRemoval; document.getElementById("lights3total").innerHTML = "$" + StreetLights; document.getElementById("townhall3total").innerHTML = "$" + TownHall; document.getElementById("townoffice3total").innerHTML = "$" + TownOffice; document.getElementById("garage3total").innerHTML = "$" + TownGarage; document.getElementById("veteran3total").innerHTML = "$" + VeteransMemorial; document.getElementById("scemetery3total").innerHTML = "$" + SebagoCemetery; document.getElementById("acemetery3total").innerHTML = "$" + AssociatedCemeteries; document.getElementById("smcemetery3total").innerHTML = "$" + SmallCemeteries; document.getElementById("sdays3total").innerHTML = "$" + SebagoDays; document.getElementById("memorial3total").innerHTML = "$" + MemorialDay; document.getElementById("recadm3total").innerHTML = "$" + RecreationAdministration; document.getElementById("douglas3total").innerHTML = "$" + DouglasMountain; document.getElementById("beach3total").innerHTML = "$" + TownBeach; document.getElementById("baseball3total").innerHTML = "$" + SYAABaseball; document.getElementById("soccer3total").innerHTML = "$" + Soccer; document.getElementById("football3total").innerHTML = "$" + Football; document.getElementById("basketball3total").innerHTML = "$" + Basketball; document.getElementById("library3total").innerHTML = "$" + Library; document.getElementById("cip3total").innerHTML = "$" + CIP; document.getElementById("countytax3total").innerHTML = "$" + CountyTax; document.getElementById("msad3total").innerHTML = "$" + MSAD61; document.getElementById("totaltowntax3").innerHTML = "$" + TotalTownTax; } // // resetForm will do what it says -- anything we calculated previously (or might have) will be set // back to zero. This will work whether we filled in anything before or not. // function resetForm() { property_calc.propvalue.value = "0"; document.getElementById("totalbill1").innerHTML = "0"; document.getElementById("countytax2").innerHTML = "0"; document.getElementById("towntax2").innerHTML = "0"; document.getElementById("schooltax2").innerHTML = "0"; document.getElementById("totalbill2").innerHTML = "0"; document.getElementById("countytax3").innerHTML = "0"; document.getElementById("schooltax3").innerHTML = "0"; document.getElementById("propvalue3a").innerHTML = "0"; document.getElementById("propvalue3b").innerHTML = "0"; document.getElementById("propvalue3c").innerHTML = "0"; document.getElementById("admin3portion").innerHTML = "0"; document.getElementById("select3portion").innerHTML = "0"; document.getElementById("manager3portion").innerHTML = "0"; document.getElementById("clerk3portion").innerHTML = "0"; document.getElementById("code3portion").innerHTML = "0"; document.getElementById("health3portion").innerHTML = "0"; document.getElementById("general3portion").innerHTML = "0"; document.getElementById("election3portion").innerHTML = "0"; document.getElementById("appeals3portion").innerHTML = "0"; document.getElementById("planning3portion").innerHTML = "0"; document.getElementById("service3portion").innerHTML = "0"; document.getElementById("alarms3portion").innerHTML = "0"; document.getElementById("animal3portion").innerHTML = "0"; document.getElementById("rescue3portion").innerHTML = "0"; document.getElementById("day3portion").innerHTML = "0"; document.getElementById("fire3portion").innerHTML = "0"; document.getElementById("dispatch3portion").innerHTML = "0"; document.getElementById("solid3portion").innerHTML = "0"; document.getElementById("hazard3portion").innerHTML = "0"; document.getElementById("debt3portion").innerHTML = "0"; document.getElementById("roads3portion").innerHTML = "0"; document.getElementById("snow3portion").innerHTML = "0"; document.getElementById("lights3portion").innerHTML = "0"; document.getElementById("townhall3portion").innerHTML = "0"; document.getElementById("townoffice3portion").innerHTML = "0"; document.getElementById("garage3portion").innerHTML = "0"; document.getElementById("veteran3portion").innerHTML = "0"; document.getElementById("scemetery3portion").innerHTML = "0"; document.getElementById("acemetery3portion").innerHTML = "0"; document.getElementById("smcemetery3portion").innerHTML = "0"; document.getElementById("sdays3portion").innerHTML = "0"; document.getElementById("memorial3portion").innerHTML = "0"; document.getElementById("recadm3portion").innerHTML = "0"; document.getElementById("douglas3portion").innerHTML = "0"; document.getElementById("beach3portion").innerHTML = "0"; document.getElementById("baseball3portion").innerHTML = "0"; document.getElementById("soccer3portion").innerHTML = "0"; document.getElementById("football3portion").innerHTML = "0"; document.getElementById("basketball3portion").innerHTML = "0"; document.getElementById("library3portion").innerHTML = "0"; document.getElementById("cip3portion").innerHTML = "0"; document.getElementById("countytax3portion").innerHTML = "0"; document.getElementById("msad3portion").innerHTML = "0"; document.getElementById("towntax3").innerHTML = "0"; document.getElementById("totalbill3").innerHTML = "0"; } // // calculateForm will do the math for all the values we've set up previously. // function calculateForm() { document.getElementById("totalbill1").innerHTML = FixNum( ((taxrate * property_calc.propvalue.value) / 1000) + ((property_calc.propvalue.value - 100000) * (taxrate / 1000) * .02 ) ); document.getElementById("countytax2").innerHTML = FixNum((countytaxrate * property_calc.propvalue.value) / 1000); document.getElementById("towntax2").innerHTML = FixNum((towntaxrate * property_calc.propvalue.value) / 1000); document.getElementById("schooltax2").innerHTML = FixNum((schooltaxrate * property_calc.propvalue.value) / 1000); document.getElementById("totalbill2").innerHTML = FixNum((taxrate * property_calc.propvalue.value) / 1000); document.getElementById("countytax3").innerHTML = FixNum((countytaxrate * property_calc.propvalue.value) / 1000); document.getElementById("schooltax3").innerHTML = FixNum((schooltaxrate * property_calc.propvalue.value) / 1000); document.getElementById("propvalue3a").innerHTML = "$" + property_calc.propvalue.value; document.getElementById("propvalue3b").innerHTML = "$" + property_calc.propvalue.value; document.getElementById("propvalue3c").innerHTML = "$" + property_calc.propvalue.value; var townPercentage = ((property_calc.propvalue.value * towntaxrate)/1000); document.getElementById("admin3portion").innerHTML = FixNum((Administration/TotalTownTax)*townPercentage); document.getElementById("select3portion").innerHTML = FixNum((Selectmen/TotalTownTax)*townPercentage); document.getElementById("manager3portion").innerHTML = FixNum((TownManager/TotalTownTax)*townPercentage); document.getElementById("clerk3portion").innerHTML = FixNum((ClerkTaxCollector/TotalTownTax)*townPercentage); document.getElementById("code3portion").innerHTML = FixNum((CodeEnforcement/TotalTownTax)*townPercentage); document.getElementById("health3portion").innerHTML = FixNum((HealthOfficer/TotalTownTax)*townPercentage); document.getElementById("general3portion").innerHTML = FixNum((GeneralAssistance/TotalTownTax)*townPercentage); document.getElementById("election3portion").innerHTML = FixNum((Elections/TotalTownTax)*townPercentage); document.getElementById("appeals3portion").innerHTML = FixNum((AppealsBoard/TotalTownTax)*townPercentage); document.getElementById("planning3portion").innerHTML = FixNum((PlanningBoard/TotalTownTax)*townPercentage); document.getElementById("service3portion").innerHTML = FixNum((ServiceProviders/TotalTownTax)*townPercentage); document.getElementById("alarms3portion").innerHTML = FixNum((Alarms/TotalTownTax)*townPercentage); document.getElementById("animal3portion").innerHTML = FixNum((AnimalControl/TotalTownTax)*townPercentage); document.getElementById("rescue3portion").innerHTML = FixNum((Rescue/TotalTownTax)*townPercentage); document.getElementById("day3portion").innerHTML = FixNum((DaytimeRescue/TotalTownTax)*townPercentage); document.getElementById("fire3portion").innerHTML = FixNum((Fire/TotalTownTax)*townPercentage); document.getElementById("dispatch3portion").innerHTML = FixNum((Dispatch/TotalTownTax)*townPercentage); document.getElementById("solid3portion").innerHTML = FixNum((SolidWaste/TotalTownTax)*townPercentage); document.getElementById("hazard3portion").innerHTML = FixNum((HazardousWaste/TotalTownTax)*townPercentage); document.getElementById("debt3portion").innerHTML = FixNum((RWSDebtService/TotalTownTax)*townPercentage); document.getElementById("roads3portion").innerHTML = FixNum((Roads/TotalTownTax)*townPercentage); document.getElementById("snow3portion").innerHTML = FixNum((SnowRemoval/TotalTownTax)*townPercentage); document.getElementById("lights3portion").innerHTML = FixNum((StreetLights/TotalTownTax)*townPercentage); document.getElementById("townhall3portion").innerHTML = FixNum((TownHall/TotalTownTax)*townPercentage); document.getElementById("townoffice3portion").innerHTML = FixNum((TownOffice/TotalTownTax)*townPercentage); document.getElementById("garage3portion").innerHTML = FixNum((TownGarage/TotalTownTax)*townPercentage); document.getElementById("veteran3portion").innerHTML = FixNum((VeteransMemorial/TotalTownTax)*townPercentage); document.getElementById("scemetery3portion").innerHTML = FixNum((SebagoCemetery/TotalTownTax)*townPercentage); document.getElementById("acemetery3portion").innerHTML = FixNum((AssociatedCemeteries/TotalTownTax)*townPercentage); document.getElementById("smcemetery3portion").innerHTML = FixNum((SmallCemeteries/TotalTownTax)*townPercentage); document.getElementById("sdays3portion").innerHTML = FixNum((SebagoDays/TotalTownTax)*townPercentage); document.getElementById("memorial3portion").innerHTML = FixNum((MemorialDay/TotalTownTax)*townPercentage); document.getElementById("recadm3portion").innerHTML = FixNum((RecreationAdministration/TotalTownTax)*townPercentage); document.getElementById("douglas3portion").innerHTML = FixNum((DouglasMountain/TotalTownTax)*townPercentage); document.getElementById("beach3portion").innerHTML = FixNum((TownBeach/TotalTownTax)*townPercentage); document.getElementById("baseball3portion").innerHTML = FixNum((SYAABaseball/TotalTownTax)*townPercentage); document.getElementById("soccer3portion").innerHTML = FixNum((Soccer/TotalTownTax)*townPercentage); document.getElementById("football3portion").innerHTML = FixNum((Football/TotalTownTax)*townPercentage); document.getElementById("basketball3portion").innerHTML = FixNum((Basketball/TotalTownTax)*townPercentage); document.getElementById("library3portion").innerHTML = FixNum((Library/TotalTownTax)*townPercentage); document.getElementById("cip3portion").innerHTML = FixNum((CIP/TotalTownTax)*townPercentage); document.getElementById("countytax3portion").innerHTML = FixNum((CountyTax/TotalTownTax)*townPercentage); document.getElementById("msad3portion").innerHTML = FixNum((MSAD61/TotalTownTax)*townPercentage); document.getElementById("towntax3").innerHTML = FixNum((towntaxrate * property_calc.propvalue.value) / 1000); document.getElementById("totalbill3").innerHTML = FixNum((taxrate * property_calc.propvalue.value) / 1000); }