I have the following switch statement. All the cases work including the ‘custom’ case. the only challenge is that I am unable to return the radval from the ‘custom’ case. It shows the right value if I do it in the console log. I have tried several options mentioned in the comment below but none works.
document.body.addEventListener('change', function (e) {
let target = e.target;
let responsible;
let radval = 0.5;;
let yourshare;
switch (target.id) {
case '100':
radval = 100/100;
break;
case '50':
radval = 50/100;
break;
case '25':
radval = 25/100;
break;
case '75':
radval = 55/100;
break;
case '33':
radval = 33/100;
break;
case '0':
radval = 0;
break;
case 'custom':
document.getElementById('customsplit').onchange = function () {
let custval = document.getElementById("customsplit");
radval = custval.value / 100;
return(radval);
// Also tried return radval and tried a function outside the switch statement that was called here. But no success.
}
break;
}