Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7507289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:27:32+00:00 2026-05-29T22:27:32+00:00

Note: It is different for IE8 and IE9. var foo = documentGetElementById( form_name ).elements;

  • 0

Note: It is different for IE8 and IE9.

   var foo = documentGetElementById( form_name ).elements;

In IE 9 foo gets an array of elements which contain values that the user submitted so that one can iterate over them like this.

for ( index in foo )
{
    if( foo[index].value === 'element_value' ) 
    {
        return 1;
    }
}

In IE 8 I don’t know what foo has in it. But I can no longer loop through elements to pull user input from the form. IE 8 debugger reports that foo[element] is NULL or not an object.

In both cases I don’t know what it is suppose to do ( as opposed to what it actually does).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:27:34+00:00Added an answer on May 29, 2026 at 10:27 pm

    Don’t use for ... in for loops like that. Instead:

        for (var index = 0; index < foo.length; ++index) {
          if (foo[index].value === 'whatever') { return 1; }
        }
    

    The for ... in form of loop is for going through properties of an Object. What you’ve got here is, indeed, an object, but more importantly it’s something that acts more like an array. (It’s a NodeList HTMLCollection, really, but for content traversal it can be treated like an array.) The advantage to iterating by numeric index is that you avoid tripping over properties of the object that really aren’t part of its conceptual contents.

    Your other problem was using “element” in that indexing expression; I don’t know what “element” is/was but you want to use the iterator variable.

    edit — The difference between what I thought the “elements” thing is (a NodeList) and what it actually is (an HTMLCollection) is that the collection API has both a numerically-indexed facade and a name-indexed facade. The thing is, if you somehow know the names external to the form, then the by-name access method makes sense. However, with what you’re doing, I’d still use a numeric iterator, because otherwise things get kind-of muddy (to me). It may be that I’m just overly paranoid, so perhaps somebody with more insight will comment or answer. The way that browsers make the IDL definitions from the DOM spec work in JavaScript is an area of some flakiness, in my opinion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Please note that this is a different question from the already answered How to
Without: ATL MFC Note: Client is executing in a different thread to that of
Note that I am not asking which to choose (MVC or MVP), but rather
I'm looking at all different sorts. Note that this is not homework (I'm in
I'm having a problem with matching against french accented characters (note that other different
Note: this is a different problem to https - it's related to privacy security
I'm trying to add different icon overlays over the icons of various files (note:
Note: This is a railsier (and more succinct) version of this question , which
Possibly related to my other question (note: different error code): Why might the fatal
From Python docs: http://docs.python.org/library/stdtypes.html#comparisons Implementation note: Objects of different types except numbers are ordered

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.