I have a dropdown list that is repeated 30 times on a page. I have created a function that should take care of the value
, but every time I step through in the browser the variable is always null
.
I am calling my select
like this:onchange="showDropDown(capability_4_1_b,this.value)"
my function:
function showDropDown(id,value) {
var nc = document.getElementById(id);
if (value === "NC" || value === "OBS") {
nc.style.display = 'block';
} else {
nc.style.display = 'none';
}
}
The div I am targeting is <div id="capability_4_1_b" style="display:none;">
I have looked in the source and the element is in the DOM
my JS files are at the bottom of the page.
The function above is how I started doing the functions
but I want to achieve this with one function. The functions work but too much repetition :).