var slivVal = document.querySelector('input[name="sliv"]').checked; slivVal = slivVal ? document.querySelector('input[name="sliv"]').value : 0;