[Javascript] variable undefined problem

hypersdc at cox.net hypersdc at cox.net
Wed May 28 11:26:26 CDT 2003


Yes. (Each itemX is a variable that is a string defined in an external js file,
right?)

Here is the contents of the .js

var item0 = "files/N_80.html";
var item1 = "files/test.html";


Thanks,
Hyper
  ----- Original Message ----- 
  From: Mckinney, Lori K 
  To: [JavaScript List] 
  Sent: Thursday, May 29, 2003 8:28 AM
  Subject: RE: [Javascript] variable undefined problem


  Each itemX is a variable that is a string defined in an external js file,
  right?

  -----Original Message-----
  From: Michael Dougherty [mailto:michael_dougherty at pbp.com]
  Sent: Thursday, May 29, 2003 10:27 AM
  To: javascript at LaTech.edu
  Subject: RE: [Javascript] variable undefined problem


  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 at LaTech.edu [mailto:javascript at LaTech.edu] 
  Sent: Thursday, May 29, 2003 8:16 AM
  To: javascript at latech.edu
  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;
   }
  } 


  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript
  _______________________________________________
  Javascript mailing list
  Javascript at LaTech.edu
  https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030528/9617ae0f/attachment.htm>


More information about the Javascript mailing list