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: michael_dougherty at pbp.com (Michael Dougherty)
  • Subject: [Javascript] variable undefined problem
  • Date: Thu May 29 10:28:25 2003

Is itemN supposed to be an object?  No context is supplied to know where
to be looking for it.

"Variable undefined" because there was no earlier "var item0 ="
statement.  If you are looking for a form object named item0, then you
need syntax like: var ItemValue = eval("document.form["myForm"].item" +
I + ".value")

-----Original Message-----
From: javascript@xxxxxxxxxx [mailto:javascript@xxxxxxxxxx] 
Sent: Thursday, May 29, 2003 8:16 AM
To: javascript@xxxxxxxxxx
Subject: RE: [Javascript] variable undefined problem
Importance: Low


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;
 }
}