Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] variable undefined problem


  • From: lkmckinn at ingr.com (Mckinney, Lori K)
  • Subject: [Javascript] variable undefined problem
  • Date: Thu May 29 08:18:29 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@xxxxxxx [mailto:hypersdc@xxxxxxx]
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.LaTech.edu/pipermail/javascript/attachments/20030529/db5ccaef/attachment.html