Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] variable undefined problem
- From: hypersdc at cox.net (hypersdc@xxxxxxx)
- Subject: [Javascript] variable undefined problem
- Date: Fri May 23 22:36:49 2003
I'm having problems with a variable undefined error.
I'm grabbing a set of variables from a file (.js file). I'm cycling through
the variables with a while statement. The problem I'm having is the last
variable is getting an undefined. How can I fix the code so this doesn't
happen.
//Start Code:
var i = 0;
var itemCheck = item0;
while(window.itemCheck)
{
document.write("<A HREF=" + itemCheck + ">" + itemCheck + "<BR></A>" );
i++;
x = "item" + i;
itemCheck =eval(x);
if (typeof eval(x) == 'undefined')
alert('2 Undefined');
else
alert('2 okay');
itemCheck =eval(x);
}
//End code
//js content
var item0 = "name 1";
var item1 = "name 2";
//end js file content
Thanks in advance
- Follow-Ups:
- [Javascript] variable undefined problem
- From: Rodney Myers
- [Javascript] variable undefined problem
- Prev by Date: [Javascript] RE: YES/NO Message box
- Next by Date: [Javascript] variable undefined problem
- Previous by thread: [Javascript] RE: YES/NO Message box
- Next by thread: [Javascript] variable undefined problem
- Index(es):