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

  • SEARCH
  • Home
  • 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 71503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:53:53+00:00 2026-05-10T19:53:53+00:00

I have some code doing this : var changes = document.getElementsByName(from); for (var c=0;

  • 0

I have some code doing this :

 var changes = document.getElementsByName(from);  for (var c=0; c<changes.length; c++) {    var ch = changes[c];    var current = new String(ch.innerHTML);    etc.  } 

This works fine in FF and Chrome but not in IE7. Presumably because getElementsByName isn’t working in IE. What’s the best workaround?

  • 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. 2026-05-10T19:53:53+00:00Added an answer on May 10, 2026 at 7:53 pm

    In case you don’t know why this isn’t working in IE, here is the MSDN documentation on that function:

    When you use the getElementsByName method, all elements in the document that have the specified NAME attribute or ID attribute value are returned.

    Elements that support both the NAME attribute and the ID attribute are included in the collection returned by the getElementsByName method, but elements with a NAME expando are not included in the collection; therefore, this method cannot be used to retrieve custom tags by name.

    Firefox allows getElementsByName() to retrieve elements that use a NAME expando, which is why it works. Whether or not that is a Good Thing™ may be up for debate, but that is the reality of it.

    So, one option is to use the getAttribute() DOM method to ask for the NAME attribute and then test the value to see if it is what you want, and if so, add it to an array. This would require, however, that you iterate over all of the nodes in the page or at least within a subsection, which wouldn’t be the most efficient. You could constrain that list beforehand by using something like getElementsByTagName() perhaps.

    Another way to do this, if you are in control of the HTML of the page, is to give all of the elements of interest an Id that varies only by number, e.g.:

    <div id="Change0">...</div> <div id="Change1">...</div> <div id="Change2">...</div> <div id="Change3">...</div> 

    And then have JavaScript like this:

    // assumes consecutive numbering, starting at 0 function getElementsByModifiedId(baseIdentifier) {     var allWantedElements = [];     var idMod = 0;     while(document.getElementById(baseIdentifier + idMod)) { // will stop when it can't find any more         allWantedElements.push(document.getElementById(baseIdentifier + idMod++));     }     return allWantedElements; }  // call it like so: var changes = getElementsByModifiedId("Change"); 

    That is a hack, of course, but it would do the job you need and not be too inefficient compare to some other hacks.

    If you are using a JavaScript framework/toolkit of some kind, you options are much better, but I don’t have time to get into those specifics unless you indicate you are using one. Personally, I don’t know how people live without one, they save so much time, effort and frustration that you can’t afford not to use one.

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

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer It will be out of scope after function returns, yes.… May 11, 2026 at 2:06 pm
  • added an answer Encode the id of the product that is selected into… May 11, 2026 at 2:06 pm
  • added an answer It seems to me that this decision often comes down… May 11, 2026 at 2:06 pm

Related Questions

I have some cross platform DNS client code that I use for doing end
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some code like this in a winforms app I was writing to
I have some code which collects points (consed integers) from a loop which looks
I already started this in javascript so I don't want to use jquery but
I got this bad feeling about how I insert larger amounts of HTML. Lets
I'm seeing something very very strange happening in a Flex app I'm maintaining. I've
I have created some extra functionality on my Linq-to-SQL classes to make things easier

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.