[Javascript] variable undefined problem
Mckinney, Lori K
lkmckinn at ingr.com
Thu May 29 08:15:31 CDT 2003
How about using something like this? I changed itemCheck to be a boolean
flag. If you didn't have an item0, that would have raised an error.
var i = 0;
var itemCheck = true;
while(window.itemCheck)
{
x = "item" + i;
try {
itemCheck =eval(x);
document.write("<A HREF=" + itemCheck + ">" + itemCheck + "<BR></A>" );
i++;
}
catch (e) {
itemCheck = false;
}
}
-----Original Message-----
From: hypersdc at cox.net [mailto:hypersdc at cox.net]
Sent: Wednesday, May 28, 2003 12:31 AM
To: [JavaScript List]
Subject: Re: [Javascript] variable undefined problem
I still have the increment and variable undefined problem.
Here is my latest revision of the code:
var i = 0;
var itemCheck = item0;
while(window.itemCheck)
{
x = "item" + i;
itemCheck =eval(x);
document.write("<A HREF=" + itemCheck + ">" + itemCheck + "<BR></A>" );
i++;
}
Any help would be appreciated as this one is driving me crazy.
The .js file that I'm getting the variables from has 2 items in it
currently.
var item0 = "files/file1.html";
var item1 = "files/file2.html";
Later it will have an unknown amount (that's why I need the while
statement).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030529/db5ccaef/attachment.htm>
More information about the Javascript
mailing list