Display/hide Input Fields Based On Radio Button Selection
I am a novice in JS and learning. Please help me in correcting the code. The inputs are: radio-button-1; radio-button-2; input-fields-set-1; input-fields-set-2; input-field-submit
Solution 1:
When I look at your code at https://testing2601.000webhostapp.com/ , I see your javascript code (from main.js) as below so if that's the case that means ageCheck
is not attached to global so it's not be defined for your HTML to use and that's your root cause on why it's not working.
(function($) {
function ageCheck() {
if (document.getElementById('below').checked) {
document.getElementById('ifBelow').style.display = 'block';
document.getElementById('ifAbove').style.display = 'none';
document.getElementById('ifChecked').style.display = 'block';
}
else if (document.getElementById('above').checked) {
document.getElementById('ifBelow').style.display = 'none';
document.getElementById('ifAbove').style.display = 'block';
document.getElementById('ifChecked').style.display = 'block';
}
else {
document.getElementById('ifAbove').style.display = 'none';
document.getElementById('ifBelow').style.display = 'none';
document.getElementById('ifChecked').style.display = 'none';
}
}
})(jQuery);
Post a Comment for "Display/hide Input Fields Based On Radio Button Selection"