test
.container-calculator{max-width:600px;margin:auto}.container-calculator label{display:block;margin-top:10px}.container-calculator input,.container-calculator select{padding:10px;width:100%;margin-top:5px}.container-calculator button{margin-top:20px;padding:10px;background-color:#4CAF50;color:#fff;border:none;cursor:pointer}.container-calculator button:hover{background-color:#45a049}.container-calculator .result{margin-top:30px;padding:20px;background-color:#f2f2f2}
Soap Calculator
Sabun Mandi Batang (NaOH)
Sabun Mandi Cair (KOH)
10%
15%
function calculateSoap() {
const soapType = document.getElementById(‘soap-type’).value;
const superfat = document.getElementById(‘superfat’).value / 100;
const coconutOil = parseFloat(document.getElementById(‘coconut-oil’).value);
const oliveOil = parseFloat(document.getElementById(‘olive-oil’).value);
const castorOil = parseFloat(document.getElementById(‘castor-oil’).value);
const ecoEnzymePercent = parseFloat(document.getElementById(‘eco-enzyme’).value) / 100;
// Saponification values for NaOH and KOH
const SAP_NAOH = { coconut: 0.183, olive: 0.135, castor: 0.128 };
const SAP_KOH = { coconut: 0.257, olive: 0.190, castor: 0.179 };
// Determine whether to use NaOH or KOH
const SAP = soapType === ‘solid’ ? SAP_NAOH : SAP_KOH;
// Calculate the required NaOH or KOH
let lye = (coconutOil * SAP.coconut) + (oliveOil * SAP.olive) + (castorOil * SAP.castor);
lye = lye * (1 – superfat); // Apply superfat
// Water Calculation (33% of oil weight for solid, 2.5x KOH for liquid)
const totalOils = coconutOil + oliveOil + castorOil;
let water = soapType === ‘solid’ ? totalOils * 0.33 : lye * 2.5;
let ecoEnzyme = water * ecoEnzymePercent;
water = water – ecoEnzyme; // Adjust water based on eco enzyme percentage
// Display the results
const resultsDiv = document.getElementById(‘results’);
resultsDiv.innerHTML = `
Recipe Results:
Total Lye (${soapType === ‘solid’ ? ‘NaOH’ : ‘KOH’}): ${lye.toFixed(2)} g
Water: ${water.toFixed(2)} g
Eco Enzyme: ${ecoEnzyme.toFixed(2)} g
`;
}