Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2fa90da5e3
Fetching contributors…

Cannot retrieve contributors at this time

130 lines (101 sloc) 3.8 kb
<html>
<head>
<title>ROI Calculator</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<style type="text/css">
label { width: 15em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
</style>
</head>
<body>
<h2>ROI Calculator</h2>
<form id="roi-form">
<fieldset>
<legend>Please fill in the fields with the "*" and then click the button for the calculation</legend>
<p>
<label for="trucks">Number of Vehicles:</label>
<em>*</em><input name="trucks" id="trucks" size="20" class="required" />
</p>
<p>
<label for="salary">Hourly Driver Salary:</label>
<em>*</em><input name="salary" id="salary" size="20" class="required" />
</p>
<p>
<label for="cpm">Cost per Mile:</label>
<em>*</em><input name="cpm" id="cpm" size="20" class="required" />
</p>
<p>
<label for="currmiles">Total Miles Driven per Vehicle:</label>
<em>*</em><input name="currmiles" id="currmiles" size="20" class="required" />
</p>
<p>
<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>
</select>
</p>
<input type="submit" id="roi-calc" value="Calculate Savings">
<br />
<h3>Daily Savings</h3>
<p>
<label for="milessaved">Daily Miles Saved:</label>
<em>&nbsp;&nbsp;</em><input type="text" name="milessaved" id="milessaved" size="20" class="roiAnswer" />
</p>
<p>
<label for="hourssaved">Daily Hours Saved:</label>
<em>&nbsp;&nbsp;</em><input type="text" name="hourssaved" id="hourssaved" size="20" class="roiAnswer" />
</p>
<p>
<label for="dailywages">Daily Wages Saved:</label>
$<input type="text" name="dailywages" id="dailywages" size="20" class="roiAnswer" />
</p>
<p>
<label for="vehcosts">Daily Vehicle Costs Saved:</label>
$<input type="text" name="vehcosts" id="vehcosts" size="20" class="roiAnswer" />
</p>
<h3>Long Term Savings</h3>
<p>
<label for="monthlysavings">Total Monthly Savings:</label>
$<input type="text" name="monthlysavings" id="monthlysavings" size="20" class="roiAnswer" />
</p>
<p>
<label for="annualsavings">Total Annual Savings:</label>
$<input type="text" name="annualsavings" id="annualsavings" size="20" class="roiAnswer" />
</p>
</fieldset>
</form>
<script type="text/javascript">
$(function() {
$("#roi-form").validate();
$("#roi-form").submit(function(e) {
e.preventDefault();
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)) {
$("#milessaved").val(milessavings.toFixed(2));
$("#hourssaved").val(hourssavings.toFixed(2));
$("#dailywages").val(dailysavings.toFixed(2));
$("#vehcosts").val(vehiclesavings.toFixed(2));
$("#monthlysavings").val(ttlmonthlysavings.toFixed(2));
$("#annualsavings").val(ttlannualsavings.toFixed(2));
} else {
$("#milessaved").val('There was an error');
}
});
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.