document.addEventListener(“DOMContentLoaded”, function() {
const imperialVolumes = {
‘8-8-12’: 2,
‘8-10-12’: 4,
‘8-12-12’: 5,
‘8-15-12’: 6,
‘8-18-12′: 8,
’10-8-14′: 3,
’10-10-14′: 4,
’10-12-14′: 6,
’10-15-14′: 7,
’10-18-14′: 9,
’12-8-16′: 4,
’12-10-16′: 5,
’12-12-16′: 7,
’12-15-16′: 9,
’12-18-16′: 10,
’15-8-18′: 4,
’15-10-18′: 5,
’15-12-18′: 8,
’15-15-18′: 10,
’15-18-18′: 12,
’18-8-24′: 5,
’18-10-24′: 7,
’18-12-24′: 10,
’18-15-24′: 13,
’18-18-24′: 16,
’24-8-30′: 7,
’24-10-30′: 9,
’24-12-30′: 13,
’24-15-30′: 16,
’24-18-30′: 20,
’30-8-36′: 7,
’30-10-36′: 11,
’30-12-36′: 16,
’30-15-36′: 20,
’30-18-36′: 24,
’36-8-48′: 9,
’36-10-48′: 15,
’36-12-48′: 21,
’36-15-48′: 26,
’36-18-48′: 32,
’48-8-53′: 10,
’48-10-53′: 16,
’48-12-53′: 23,
’48-15-53′: 29,
’48-18-53′: 35,
’53-8-60′: 12,
’53-10-60′: 18,
’53-12-60′: 26,
’53-15-60′: 33,
’53-18-60′: 39
};
const metricVolumes = {
’20-20-30′: 10,
’20-25-30′: 16,
’20-30-30′: 23,
’20-38-30′: 29,
’20-45-30′: 35,
’25-20-36′: 12,
’25-25-36′: 19,
’25-30-36′: 27,
’25-38-36′: 34,
’25-45-36′: 41,
’30-20-41′: 14,
’30-25-41′: 22,
’30-30-41′: 31,
’30-38-41′: 39,
’30-45-41′: 47,
’38-20-46′: 15,
’38-25-46′: 24,
’38-30-46′: 35,
’38-38-46′: 44,
’38-45-46′: 53,
’45-20-61′: 21,
’45-25-61′: 33,
’45-30-61′: 47,
’45-38-61′: 59,
’45-45-61′: 71,
’61-20-76′: 26,
’61-25-76′: 41,
’61-30-76′: 59,
’61-38-76′: 74,
’61-45-76′: 89,
’76-20-91′: 31,
’76-25-91′: 49,
’76-30-91′: 71,
’76-38-91′: 89,
’76-45-91′: 107,
’91-20-122′: 42,
’91-25-122′: 66,
’91-30-122′: 95,
’91-38-122′: 119,
’91-45-122’: 143,
‘122-20-135’: 47,
‘122-25-135’: 73,
‘122-30-135’: 105,
‘122-38-135’: 132,
‘122-45-135’: 158,
‘135-20-152’: 53,
‘135-25-152’: 83,
‘135-30-152’: 119,
‘135-38-152’: 149,
‘135-45-152’: 179
};
function calculateVolume() {
const width = document.getElementById(‘width’).value;
const depth = document.getElementById(‘depth’).value;
const length = document.getElementById(‘length’).value;
const key = `${width}-${depth}-${length}`;
console.log(“Key:”, key); // Log the generated key
let volume = 0;
if (imperialVolumes[key]) {
volume = imperialVolumes[key];
} else if (metricVolumes[key]) {
volume = metricVolumes[key];
}
console.log(“Volume:”, volume); // Log the calculated volume
document.getElementById(‘volume’).innerText = volume;
}