Birth Control CalculatorCompare the real-world cost of contraceptive methods over time, pills, patches, rings, IUDs, implants, condoms and more 💊
Cost Result
You will spend
$0
over 1 year
$0 / year
$0 / month
💰 —
Costs are estimates based on typical U.S. retail prices. Actual costs vary widely — many insurance plans cover contraception with no copay under the ACA. Check with your insurance provider or a local clinic.
Calculate
Reset
Copy
Share
Embed
Info
Embed this calculator
Embed code
Copy Embed Code
Refresh Preview
Close
Live preview — identical to the main calculator
EXACT MATCH
\n';
}function sizeEmbedPreview() {
if (!embedPreview) return;
try {
var doc = embedPreview.contentDocument || embedPreview.contentWindow.document;
if (doc && doc.body) {
var h = doc.body.scrollHeight || doc.documentElement.scrollHeight;
if (h && h > 400) {
embedPreview.style.height = Math.min(h + 24, 4000) + 'px';
}
}
} catch (e) {}
}function generateEmbedCode() {
if (!embedPanel || embedPanel.style.display !== 'block') {
if (embedCodeTextarea) embedCodeTextarea.value = buildToolHtml();
return;
}
var toolHtml = buildToolHtml();
if (embedCodeTextarea) embedCodeTextarea.value = toolHtml;
if (embedPreview) {
embedPreview.onload = function () { sizeEmbedPreview(); };
embedPreview.srcdoc = toolHtml;
}
}var embedRefreshTimer = null;
function scheduleEmbedRefresh() {
if (!embedPanel || embedPanel.style.display !== 'block') return;
if (embedRefreshTimer) clearTimeout(embedRefreshTimer);
embedRefreshTimer = setTimeout(function () {
embedRefreshTimer = null;
generateEmbedCode();
}, 450);
}window.toggleEmbedPanel = function () {
if (!embedPanel) return;
var isHidden = (embedPanel.style.display === 'none' || embedPanel.style.display === '');
if (isHidden) {
embedPanel.style.display = 'block';
generateEmbedCode();
try { embedPanel.scrollIntoView({ behavior:'smooth', block:'start' }); } catch (e) {}
} else {
embedPanel.style.display = 'none';
}
};window.closeEmbed = function () { if (embedPanel) embedPanel.style.display = 'none'; };
window.refreshEmbed = function () { generateEmbedCode(); };window.copyEmbedCode = function () {
if (!embedCodeTextarea) return;
generateEmbedCode();
embedCodeTextarea.select();
embedCodeTextarea.setSelectionRange(0, embedCodeTextarea.value.length);
if (navigator.clipboard) {
navigator.clipboard.writeText(embedCodeTextarea.value).then(function () { alert('Embed code copied!'); })
.catch(function () {
try { document.execCommand('copy'); alert('Embed code copied!'); }
catch (e) { alert('Press Ctrl+C to copy'); }
});
} else {
try { document.execCommand('copy'); alert('Embed code copied!'); }
catch (e) { alert('Press Ctrl+C to copy'); }
}
};/* ─────────── init ─────────── */
function bindAll() {
Array.prototype.forEach.call(genderSeg.querySelectorAll('button'), function (btn) {
btn.addEventListener('click', function () {
onGenderChange(btn.getAttribute('data-gender'));
});
});
Array.prototype.forEach.call(condomSeg.querySelectorAll('button'), function (btn) {
btn.addEventListener('click', function () {
onCondomChange(btn.getAttribute('data-condom') === 'yes');
});
});if (methodSelect) methodSelect.addEventListener('change', function () {
applyMethodDefaults();
calculate();
scheduleEmbedRefresh();
});
if (costInput) costInput.addEventListener('input', function () { calculate(); scheduleEmbedRefresh(); });
if (costInput) costInput.addEventListener('change', function () { calculate(); });
if (condomCostInput) condomCostInput.addEventListener('input', function () { calculate(); scheduleEmbedRefresh(); });
if (condomFreqInput) condomFreqInput.addEventListener('input', function () { calculate(); scheduleEmbedRefresh(); });
if (presetSelect) presetSelect.addEventListener('change', onPresetChange);
if (yearsRange) yearsRange.addEventListener('input', function () {
var v = parseInt(yearsRange.value, 10) || 1;
yearsValue.textContent = v;
yearsUnit.textContent = (v === 1 ? 'yr' : 'yrs');
calculate();
scheduleEmbedRefresh();
});
}function init() {
populatePresets();
populateMethodSelect();
methodSelect.value = 'pill';
applyMethodDefaults();
bindAll();
calculate();
if (embedPanel) embedPanel.style.display = 'none';
}if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();