function calculation_bw () { let width = document.getElementById('box_unit_width').value; let length = document.getElementById('box_unit_length').value; let height = document.getElementById('box_unit_height').value; let wType = document.querySelector(`input[name="box_radio"]:checked`).value; let result = 0; let targetInput = document.getElementById('weight'); if (checkVariables(width, length, height)) { if (wType === 'kg') { result = ((width * height * length) / 6000).toFixed(3) + ' KG'; } else { result = ((width * height * length) / 166).toFixed(3) + ' ib'; } } else { alert('입력값을 확인하세요'); return false; } targetInput.value = result; } function calculation_cw () { let width = document.getElementById('cy_unit_width').value; let length = document.getElementById('cy_unit_length').value; let wType = document.querySelector(`input[name="cy_radio"]:checked`).value; let result = 0; let targetInput = document.getElementById('weight2'); if (checkVariables(width, length)) { if (wType === 'kg') { result = (((Math.round(width * width * Math.PI * 1000) / 1000) * length) / 6000).toFixed(3) + ' KG'; } else { result = (((Math.round(width * width * Math.PI * 1000) / 1000) * length) / 166).toFixed(3) + ' ib'; } } else { alert('입력값을 확인하세요'); return false; } targetInput.value = result; } function calculation_bc () { let width = document.getElementById('box_unit_width1').value; let length = document.getElementById('box_unit_length1').value; let height = document.getElementById('box_unit_height1').value; let count = document.getElementById('box_unit_count').value; let wType = document.querySelector(`input[name="box_radio1"]:checked`).value; let result = 0; let targetInput = document.getElementById('weight3'); if (checkVariables(width, length, height)) { if (wType === 'kg') { result = ((width * height * length) / 1000000).toFixed(3) + ' CBM'; } else { result = (((width * height * length) / 1728) / 35.3147).toFixed(3) + ' CBM'; } } else { alert('입력값을 확인하세요'); return false; } targetInput.value = result; } function calculation_cc () { let width = document.getElementById('box_unit_width1').value; let length = document.getElementById('box_unit_length1').value; let height = document.getElementById('box_unit_height1').value; let count = document.getElementById('box_unit_count').value; let wType = document.querySelector(`input[name="box_radio1"]:checked`).value; let result = 0; let targetInput = document.getElementById('weight4'); if (checkVariables(width, length, height)) { if (wType === 'kg') { result = (((Math.round(width * width * Math.PI * 1000) / 1000) * length) / 1000000).toFixed(3) + ' CBM'; } else { result = (((width * height * length) / 1728) / 35.3147).toFixed(3) + ' CBM'; } } else { alert('입력값을 확인하세요'); return false; } targetInput.value = result; } function checkVariables() { for (let i = 0; i < arguments.length; i++) { // 변수가 null 또는 undefined이면 false 반환 if (arguments[i] === null || arguments[i] === undefined) { return false; } // 변수가 숫자가 아니면 false 반환 if (isNaN(arguments[i])) { return false; } } // 모든 변수가 조건을 만족하면 true 반환 return true; }