×
    Get a Quote

    Monthly Marketing SEO Investment Calculator

    Firm Name
    Market
    Practice Area
    Attorneys
    Email
    X - Close
    document.addEventListener('DOMContentLoaded', function() { const form = document.getElementById('seo-calculator'); const nextButton = document.getElementById('next-step'); const quoteButton = document.getElementById('get-quote'); const quoteResult = document.getElementById('quote-result'); const monthlyCost = document.getElementById('monthly-cost'); const progressSteps = document.querySelectorAll('.progress-step'); let currentStep = 1; nextButton.addEventListener('click', () => { const currentStepElement = document.getElementById(`step${currentStep}`); if (currentStepElement.checkValidity()) { currentStepElement.style.display = 'none'; currentStep++; document.getElementById(`step${currentStep}`).style.display = 'block'; updateProgress(); if (currentStep === 5) { nextButton.style.display = 'none'; quoteButton.style.display = 'block'; } } else { currentStepElement.reportValidity(); } }); form.addEventListener('submit', async (e) => { e.preventDefault(); const formData = new FormData(form); const attorneyCount = parseInt(formData.get('attorney-count')); const primaryMarket = formData.get('primary-market'); const practiceArea = formData.get('practice-area'); let monthlyCostValue = 0; if (attorneyCount <= 2) { monthlyCostValue = 2000; } else if (attorneyCount <= 10) { monthlyCostValue = 2000 + (attorneyCount - 2) * 500; } else { monthlyCostValue = "Custom quote needed"; } // Census API call for population const apiKey = '371438302cf06c252754f5e902981dac5c69b46a'; const response = await fetch(`https://api.census.gov/data/2019/pep/population?get=POP&for=place:*&in=state:*&key=${apiKey}`); const data = await response.json(); const cityPopulation = data.find(city => city[3].toLowerCase().includes(primaryMarket.toLowerCase())); if (cityPopulation && parseInt(cityPopulation[0]) > 1000000) { if (typeof monthlyCostValue === 'number') { monthlyCostValue += 1000; } } if (practiceArea === 'Personal Injury' && cityPopulation && parseInt(cityPopulation[0]) > 100000) { if (typeof monthlyCostValue === 'number') { monthlyCostValue += 1000; } } monthlyCost.textContent = typeof monthlyCostValue === 'number' ? `$${monthlyCostValue.toLocaleString()}` : monthlyCostValue; form.style.display = 'none'; quoteResult.style.display = 'block'; }); function updateProgress() { progressSteps.forEach((step, index) => { if (index < currentStep) { step.classList.add('active'); } else { step.classList.remove('active'); } }); } // Autocomplete for Primary Market const primaryMarketInput = document.getElementById('primary-market'); const marketSize = document.getElementById('market-size'); primaryMarketInput.addEventListener('input', async () => { const input = primaryMarketInput.value; if (input.length > 2) { const apiKey = '371438302cf06c252754f5e902981dac5c69b46a'; const response = await fetch(`https://api.census.gov/data/2019/pep/population?get=NAME,POP&for=place:*&in=state:*&key=${apiKey}`); const data = await response.json(); const matchingCities = data.filter(city => city[0].toLowerCase().includes(input.toLowerCase())); const datalist = document.getElementById('city-suggestions') || document.createElement('datalist'); datalist.id = 'city-suggestions'; datalist.innerHTML = ''; matchingCities.forEach(city => { const option = document.createElement('option'); option.value = city[0]; datalist.appendChild(option); }); primaryMarketInput.setAttribute('list', 'city-suggestions'); document.body.appendChild(datalist); } }); primaryMarketInput.addEventListener('change', () => { const selectedCity = primaryMarketInput.value; const apiKey = '371438302cf06c252754f5e902981dac5c69b46a'; fetch(`https://api.census.gov/data/2019/pep/population?get=NAME,POP&for=place:*&in=state:*&key=${apiKey}`) .then(response => response.json()) .then(data => { const cityData = data.find(city => city[0] === selectedCity); if (cityData) { marketSize.textContent = `Market Size: ${parseInt(cityData[1]).toLocaleString()} people`; } }); }); });