• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript DOM Node-Traversal and the "Dreaded" Undefined Errors

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am currently trying to convert some horrendous IE 7-specific JavaScript DOM codes into W3C-compliant DOM JavaScripts... Unfortunately, I've been hitting a lot of brickwalls where I try to translate an IE 7-specific JS-DOM property to a W3C compliant JS-DOM property - only to get the dreaded "undefined" error message in my Safari Error Console.

Take for example the following:

I've been wading through a lot of IE JS-DOM codes that end up giving me what Safari recognizes as HTMLFormElement node object. In Safari's Debug Mode, I see the HTMLFormElement node object is full of blank HTMLInputElement node objects. So I thought I could just do a HTMLFormElement.item(0), HTMLFormElement.item(1), etc... to select each of these HTMLInputElement node objects even though they are shown as blank in the debug window...

However - as soon as my JS hits HTMLFormElement.item(0) - the console says "undefined". Which doesn't make sense - cause HTMLFormElement.length = 100 (so there's definitely child-nodes in there.) At this point, I'm getting kind of lost on what to do, cause Safari is blatantly telling me HTMLFormElement exists - with length of 100, but I can't access even the 0-index item of it...

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you mean HTMLFormElement.item(0) or HTMLFormElement.item[0]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show some code.

Eric
 
Perry Terrance
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:Show some code.

Eric



myForm = HTMLFormElement

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are Bear mentioned, it should be () and not square brackets. It is a method on the DOM HTMLCollection.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic