Fedex Next Day Shipping Calculator
.fedex-next-day-calculator {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 700px;
margin: 20px auto;
padding: 25px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #fdfdfd;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.fedex-next-day-calculator h2 {
color: #333;
text-align: center;
margin-bottom: 25px;
font-size: 26px;
}
.fedex-next-day-calculator h3 {
color: #444;
margin-top: 30px;
margin-bottom: 15px;
font-size: 20px;
}
.fedex-next-day-calculator p {
color: #555;
line-height: 1.6;
margin-bottom: 15px;
}
.fedex-next-day-calculator .calculator-form .form-group {
margin-bottom: 18px;
}
.fedex-next-day-calculator label {
display: block;
margin-bottom: 7px;
font-weight: bold;
color: #444;
font-size: 15px;
}
.fedex-next-day-calculator input[type="text"],
.fedex-next-day-calculator input[type="number"],
.fedex-next-day-calculator select {
width: calc(100% – 22px);
padding: 12px 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
color: #333;
box-sizing: border-box;
}
.fedex-next-day-calculator input[type="number"]::-webkit-inner-spin-button,
.fedex-next-day-calculator input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.fedex-next-day-calculator input[type="number"] {
-moz-appearance: textfield;
}
.fedex-next-day-calculator small {
display: block;
margin-top: 5px;
color: #777;
font-size: 13px;
}
.fedex-next-day-calculator button {
display: block;
width: 100%;
padding: 14px 20px;
background-color: #4d148c; /* FedEx Purple */
color: white;
border: none;
border-radius: 5px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 25px;
}
.fedex-next-day-calculator button:hover {
background-color: #662a99;
}
.fedex-next-day-calculator .calculator-result {
margin-top: 30px;
padding: 20px;
border: 1px solid #d4edda;
background-color: #eaf7ee;
border-radius: 8px;
color: #155724;
font-size: 17px;
line-height: 1.8;
font-weight: bold;
}
.fedex-next-day-calculator .calculator-result p {
margin-bottom: 8px;
color: #155724;
}
.fedex-next-day-calculator .calculator-result strong {
color: #0a3612;
}
.fedex-next-day-calculator ul {
list-style-type: disc;
margin-left: 20px;
margin-bottom: 15px;
color: #555;
}
.fedex-next-day-calculator ol {
list-style-type: decimal;
margin-left: 20px;
margin-bottom: 15px;
color: #555;
}
.fedex-next-day-calculator li {
margin-bottom: 8px;
line-height: 1.5;
}
.fedex-next-day-calculator .calculator-article {
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid #eee;
}
function calculateShippingCost() {
var originZip = document.getElementById("originZip").value;
var destinationZip = document.getElementById("destinationZip").value;
var packageWeight = parseFloat(document.getElementById("packageWeight").value);
var packageLength = parseFloat(document.getElementById("packageLength").value);
var packageWidth = parseFloat(document.getElementById("packageWidth").value);
var packageHeight = parseFloat(document.getElementById("packageHeight").value);
var declaredValue = parseFloat(document.getElementById("declaredValue").value);
var deliveryType = document.getElementById("deliveryType").value;
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
// — Input Validation —
if (!originZip || originZip.length !== 5 || isNaN(parseInt(originZip))) {
resultDiv.innerHTML = "Please enter a valid 5-digit Origin Zip Code.";
return;
}
if (!destinationZip || destinationZip.length !== 5 || isNaN(parseInt(destinationZip))) {
resultDiv.innerHTML = "Please enter a valid 5-digit Destination Zip Code.";
return;
}
if (isNaN(packageWeight) || packageWeight <= 0) {
resultDiv.innerHTML = "Please enter a valid Package Weight (must be a positive number).";
return;
}
if (isNaN(packageLength) || packageLength <= 0 || isNaN(packageWidth) || packageWidth <= 0 || isNaN(packageHeight) || packageHeight <= 0) {
resultDiv.innerHTML = "Please enter valid positive Package Dimensions (Length, Width, Height).";
return;
}
if (isNaN(declaredValue) || declaredValue DECLARED_VALUE_THRESHOLD) {
var valueOverThreshold = declaredValue – DECLARED_VALUE_THRESHOLD;
declaredValueSurcharge = valueOverThreshold * DECLARED_VALUE_RATE;
if (declaredValueSurcharge < DECLARED_VALUE_MIN_SURCHARGE) {
declaredValueSurcharge = DECLARED_VALUE_MIN_SURCHARGE; // Apply minimum if calculated is less
}
}
estimatedCost += declaredValueSurcharge;
// — Display Results —
resultDiv.innerHTML =
"Estimated Shipping Cost Details:" +
"Actual Package Weight: " + packageWeight.toFixed(2) + " lbs" +
"Dimensional Weight: " + dimensionalWeight.toFixed(2) + " lbs" +
"Billable Weight: " + billableWeight.toFixed(2) + " lbs" +
"Base Next Day Air Fee: $" + BASE_NEXT_DAY_FEE.toFixed(2) + "" +
"Weight-based Cost (" + billableWeight.toFixed(2) + " lbs @ $" + RATE_PER_BILLABLE_POUND.toFixed(2) + "/lb): $" + (billableWeight * RATE_PER_BILLABLE_POUND).toFixed(2) + "" +
(deliveryType === "residential" ? "Residential Delivery Surcharge: $" + RESIDENTIAL_SURCHARGE.toFixed(2) + "" : "") +
(declaredValueSurcharge > 0 ? "Declared Value Surcharge: $" + declaredValueSurcharge.toFixed(2) + "" : "") +
"Total Estimated Cost: $" + estimatedCost.toFixed(2) + "" +
"This is an estimation based on a simplified model and hypothetical rates. Actual FedEx costs may vary.";
}