Forum Moderators: open
I have a control checkbox which on click class my toggle function. The issue is that I can't seem to access the mybox[] elements using a variable in a for loop. eg.
function toggleMe()
{
if(document.addRound.enableMybox.checked)
{
for(i=0; i < 10; i++)
{
adj = i + 1;
document.addRound.elements[mybox[adj]].disabled=false;
}
}
}
I get the alert that document.addRound.elements[mybox[adj]] is undefined. I've tried a number of different ways to access the element but nothing works. As a note, it does work if I put the variable in manually ie.:
document.addRound.elements['mybox[1]'].disabled=false;
I mention this to demonstrate that there are no naming issues up to the point of accessing the element.
Any help would be appreciated.
function toggleMe()
{
if(document.addRound.enableMybox.checked)
{
for(var str, i=0; i < 10; i++)
{
str = 'mybox['+ (i + 1) +'];
document.addRound.elements[str].disabled=false;
}
}
}