this code works, and it alerts the variable every time.
var idNumber;
var elements;
var id;
var blockerIds=[];
var whileLoop=0;
while (whileLoop<112) {
elements=document.getElementsByName('bid');
id=elements[whileLoop].getAttribute('id');
blockerIds[whileLoop]=id;
alert(blockerIds[whileLoop]);
whileLoop++;
}
but I tried alerting it outside of the while statement, like this:
var idNumber;
var elements;
var id;
var blockerIds=[];
var whileLoop=0;
while (whileLoop<112) {
elements=document.getElementsByName('bid');
id=elements[whileLoop].getAttribute('id');
blockerIds[whileLoop]=id;
whileLoop++;
}
alert(blockerIds);
but it only says "undefined". Does anyone know how I can use this variable outside of the while statement, or does it seem like it should work perfectly?
bid? What are theirids?console.log()instead ofalert, then you also see other error messages, when they occur.