Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (101 sloc) 3.71 KB
<title>ROI Calculator</title>
<script src=""></script>
<script src=""></script>
<style type="text/css">
label { width: 15em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
<h2>ROI Calculator</h2>
<form id="roi-form">
<legend>Please fill in the fields with the "*" and then click the button for the calculation</legend>
<label for="trucks">Number of Vehicles:</label>
<em>*</em><input name="trucks" id="trucks" size="20" class="required" />
<label for="salary">Hourly Driver Salary:</label>
<em>*</em><input name="salary" id="salary" size="20" class="required" />
<label for="cpm">Cost per Mile:</label>
<em>*</em><input name="cpm" id="cpm" size="20" class="required" />
<label for="currmiles">Total Miles Driven per Vehicle:</label>
<em>*</em><input name="currmiles" id="currmiles" size="20" class="required" />
<label for="list">Estimated Mileage Reduction:</label>
<em>*</em><select id="list" class="required">
<option value='0'>Select the Savings.....</option>
<option value='10'>10 %</option>
<option value='15'>15 %</option>
<option value='20'>20 %</option>
<input type="submit" id="roi-calc" value="Calculate Savings">
<br />
<h3>Daily Savings</h3>
<label for="milessaved">Daily Miles Saved:</label>
<em>&nbsp;&nbsp;</em><input type="text" name="milessaved" id="milessaved" size="20" class="roiAnswer" />
<label for="hourssaved">Daily Hours Saved:</label>
<em>&nbsp;&nbsp;</em><input type="text" name="hourssaved" id="hourssaved" size="20" class="roiAnswer" />
<label for="dailywages">Daily Wages Saved:</label>
$<input type="text" name="dailywages" id="dailywages" size="20" class="roiAnswer" />
<label for="vehcosts">Daily Vehicle Costs Saved:</label>
$<input type="text" name="vehcosts" id="vehcosts" size="20" class="roiAnswer" />
<h3>Long Term Savings</h3>
<label for="monthlysavings">Total Monthly Savings:</label>
$<input type="text" name="monthlysavings" id="monthlysavings" size="20" class="roiAnswer" />
<label for="annualsavings">Total Annual Savings:</label>
$<input type="text" name="annualsavings" id="annualsavings" size="20" class="roiAnswer" />
<script type="text/javascript">
$(function() {
$("#roi-form").submit(function(e) {
var trucks = parseInt($("#trucks").val());
var salary = parseFloat($("#salary").val());
var cpm = parseFloat($("#cpm").val());
var miles = parseInt($("#currmiles").val());
var reduction = parseInt($("#list").val())/100;
var milessavings = trucks * (miles * reduction);
var hourssavings = 1/(60 / milessavings);
var dailysavings = salary * hourssavings;
var vehiclesavings = cpm * milessavings;
var ttlmonthlysavings = 20 * (dailysavings + vehiclesavings);
var ttlannualsavings = 12 * ttlmonthlysavings;
if(!isNaN(milessavings)) {
} else {
$("#milessaved").val('There was an error');
Something went wrong with that request. Please try again.