I would like to show input text field on radio button selection in vanilla JavaScript.
What am I missing?
const form = document.querySelector("form");
const size = form.elements.size;
const total = form.elements.total;
total.style.display = "none";
for (var i = 0; i < size.length; i++) {
size[i].onclick = function() {
if (this.checked) {
total.style.setProperty("display", "inherit");
total.value = this.value;
} else {
total.style.setProperty("display", "none");
}
}
}
Check this on Fiddle
Hope this will be helpful.