Fence Costs Calculator
<div class=”fencecost-calculator”> <h2>Fence Costs Calculator</h2> <div class=”fencecost-form”> <div class=”fencecost-input-group”> <label for=”fencecost-length”>Fence Length (feet):</label> <input type=”number” id=”fencecost-length” min=”0″ placeholder=”Enter fence length” step=”0.01″> </div> <div class=”fencecost-input-group”> <label for=”fencecost-height”>Fence Height (feet):</label> <input type=”number” id=”fencecost-height” min=”0″ placeholder=”Enter fence height” step=”0.01″> </div> <div class=”fencecost-input-group”> <label for=”material-cost”>Material Cost per Linear Foot:</label> <div class=”fencecost-currency-input”> <span class=”fencecost-currency-sign”>$</span> <input type=”number” id=”material-cost” min=”0″ placeholder=”Enter material cost” step=”0.01″> </div> </div> <div class=”fencecost-input-group”> <label for=”num-posts”>Number of Posts:</label> <input type=”number” id=”num-posts” min=”0″ placeholder=”Enter number of posts” step=”1″ value=”0″> </div> <div class=”fencecost-input-group”> <label for=”post-cost”>Cost per Post:</label> <div class=”fencecost-currency-input”> <span class=”fencecost-currency-sign”>$</span> <input type=”number” id=”post-cost” min=”0″ placeholder=”Enter cost per post” step=”0.01″ value=”0″> </div> </div> <div class=”fencecost-input-group”> <label for=”num-gates”>Number of Gates (Optional):</label> <input type=”number” id=”num-gates” min=”0″ placeholder=”Enter number of gates” step=”1″ value=”0″> </div> <div class=”fencecost-input-group”> <label for=”gate-cost”>Cost per Gate:</label> <div class=”fencecost-currency-input”> <span class=”fencecost-currency-sign”>$</span> <input type=”number” id=”gate-cost” min=”0″ placeholder=”Enter cost per gate” step=”0.01″ value=”0″> </div> </div> <div class=”fencecost-input-group”> <label for=”labor-cost”>Labor Cost per Linear Foot (Optional):</label> <div class=”fencecost-currency-input”> <span class=”fencecost-currency-sign”>$</span> <input type=”number” id=”labor-cost” min=”0″ placeholder=”Enter labor cost” step=”0.01″ value=”0″> </div> </div> <div class=”fencecost-buttons-container”> <button id=”fencecost-calculate-btn” onclick=”calculateFenceCost()”>Calculate</button> <button id=”fencecost-reset-btn” onclick=”location.reload()”>Reset</button> </div> </div> <div id=”fencecost-result” class=”fencecost-result-container” style=”display:none;”> <div class=”fencecost-result-item”> <span class=”fencecost-result-label”>Material Cost:</span> <span class=”fencecost-result-value”><span class=”fencecost-currency-sign”>$</span><span id=”total-material”>0.00</span></span> </div> <div class=”fencecost-result-item”> <span class=”fencecost-result-label”>Posts Cost:</span> <span class=”fencecost-result-value”><span class=”fencecost-currency-sign”>$</span><span id=”total-posts”>0.00</span></span> </div> <div class=”fencecost-result-item” id=”gates-row”> <span class=”fencecost-result-label”>Gates Cost:</span> <span class=”fencecost-result-value”><span class=”fencecost-currency-sign”>$</span><span id=”total-gates”>0.00</span></span> </div> <div class=”fencecost-result-item” id=”labor-row”> <span class=”fencecost-result-label”>Labor Cost:</span> <span class=”fencecost-result-value”><span class=”fencecost-currency-sign”>$</span><span id=”total-labor”>0.00</span></span> </div> <div class=”fencecost-result-item fencecost-total”> <span class=”fencecost-result-label”>Total Cost:</span> <span class=”fencecost-result-value”><span class=”fencecost-currency-sign”>$</span><span id=”grand-total”>0.00</span></span> </div> </div> </div> <style> .fencecost-calculator { max-width: 450px; margin: 40px auto; padding: 30px 25px; background: #fff; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.1); } .fencecost-calculator h2 { text-align: center; color: #333; margin-bottom: 24px; border-bottom: 2px solid #4A70A9; padding-bottom: 10px; } .fencecost-input-group { margin-bottom: 20px; } .fencecost-input-group label { display: block; margin-bottom: 8px; color: #333; font-weight: 500; } .fencecost-currency-input { display: flex; align-items: center; } .fencecost-currency-sign { color: #555; margin-right: 8px; font-size: 1.05em; font-weight: 500; } .fencecost-input-group input[type=”number”] { width: 100%; padding: 12px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 15px; box-sizing: border-box; color: #222; background: #fafcff; } .fencecost-input-group input[type=”number”]:focus { border-color: #4A70A9; outline: none; box-shadow: 0 0 0 2px rgba(74,112,169,0.1); } .fencecost-buttons-container { display: flex; justify-content: center; gap: 16px; margin-top: 28px; } #fencecost-calculate-btn, #fencecost-reset-btn { padding: 12px 28px; border: none; border-radius: 6px; cursor: pointer; font-size: 16px; font-weight: 500; transition: background 0.25s; box-shadow: 0 2px 4px rgba(0,0,0,0.1); } #fencecost-calculate-btn { background: #4A70A9; color: #fff; } #fencecost-calculate-btn:hover { background: #8FABD4; } #fencecost-reset-btn { background: #8FABD4; color: #fff; } #fencecost-reset-btn:hover { background: #4A70A9; } .fencecost-result-container { margin-top: 30px; padding: 20px; background: #f2f6f6; border-radius: 8px; border-left: 4px solid #4A70A9; } .fencecost-result-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #ddd; } .fencecost-result-item:last-child { border-bottom: none; } .fencecost-result-label { color: #444; font-weight: 500; } .fencecost-result-value { color: #222; font-weight: 700; } .fencecost-total { margin-top: 10px; padding-top: 15px; border-top: 2px solid #4A70A9; } .fencecost-total .fencecost-result-value { color: #4A70A9; font-size: 1.1em; } </style> <script> function calculateFenceCost() { var fenceLength = parseFloat(document.getElementById(‘fencecost-length’).value); var fenceHeight = parseFloat(document.getElementById(‘fencecost-height’).value); var materialCost = parseFloat(document.getElementById(‘material-cost’).value); var numPosts = parseFloat(document.getElementById(‘num-posts’).value); var postCost = parseFloat(document.getElementById(‘post-cost’).value); var numGates = parseFloat(document.getElementById(‘num-gates’).value); var gateCost = parseFloat(document.getElementById(‘gate-cost’).value); var laborCost = parseFloat(document.getElementById(‘labor-cost’).value); if (isNaN(fenceLength) || fenceLength <= 0 || isNaN(fenceHeight) || fenceHeight <= 0 || isNaN(materialCost) || materialCost < 0) { alert(“Please enter valid values for fence length, height, and material cost.”); return; } if (isNaN(numPosts)) numPosts = 0; if (isNaN(postCost)) postCost = 0; if (isNaN(numGates)) numGates = 0; if (isNaN(gateCost)) gateCost = 0; if (isNaN(laborCost)) laborCost = 0; var totalMaterial = fenceLength * materialCost; var totalPosts = numPosts * postCost; var totalGates = numGates * gateCost; var totalLabor = fenceLength * laborCost; var grandTotal = totalMaterial + totalPosts + totalGates + totalLabor; document.getElementById(‘total-material’).textContent = totalMaterial.toFixed(2); document.getElementById(‘total-posts’).textContent = totalPosts.toFixed(2); document.getElementById(‘total-gates’).textContent = totalGates.toFixed(2); document.getElementById(‘total-labor’).textContent = totalLabor.toFixed(2); document.getElementById(‘grand-total’).textContent = grandTotal.toFixed(2); if (totalGates > 0) { document.getElementById(‘gates-row’).style.display = ‘flex’; } else { document.getElementById(‘gates-row’).style.display = ‘none’; } if (totalLabor > 0) { document.getElementById(‘labor-row’).style.display = ‘flex’; } else { document.getElementById(‘labor-row’).style.display = ‘none’; } document.getElementById(‘fencecost-result’).style.display = ‘block’; } </script>