I have a Javascript function that dynamically creates a box with document.getElementById('lightbox').innerHTML. In the box will be, among other things, a div with id="div1" and visibility="hidden" and a form which, onSubmit, calls the function myFunction.
The function basically looks like
myFunction() {
document.getElementById('div1').style.visibility = 'visible';
}
which has worked just fine up to this point.
Now I'm trying to make the function dynamic by passing the variable "div1" into the function and make it look like
myFunction(var1) {
document.getElementById(var1).style.visibility = 'visible';
}
but it keeps giving me the error "document.getElementById(var1) is null".
When looking through the source code I can't find the "div1" div since it was created with Javascript, and I assume this is the problem. Yet it worked just fine before I tried making the function dynamic.
Halp.