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 7196669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:49:21+00:00 2026-05-28T20:49:21+00:00

I used HTML collection object as an array and adding the elements into it.

  • 0

I used HTML collection object as an array and adding the elements into it. The below code,

var claimantEmailValues = document.getElementsByName("claimantEmails");
var defendantEmailValues = document.getElementsByName("defendantEmails");


var k = defendantEmailValues.length;
for(var i=0; i<claimantEmailValues.length;i++){
        defendantEmailValues[k++] = claimantEmailValues[i];
}

At the end, length of defendantEmailValues should be 4 as I have two HTML input elements each for claimantEmails and defendantEmails. Instead the length is 2 and there was no errors. Its working well in all the versions of firefox except firefox 10. Can you someone please explain why?

  • 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-28T20:49:21+00:00Added an answer on May 28, 2026 at 8:49 pm

    JavaScript arrays are objects with a magic length property that increases when you set a numeric property equal to or above the current length. HTMLCollection objects have a length property, but it is not magic and should not increase when you set a numeric property. When you add an element to them, you’re really just adding a named property to an object, using a number as the property name.

    You’re better off converting the collections to arrays first using Array.prototype.slice:

    var slice = Array.prototype.slice,
        claimantEmailValues = slice.call(document.getElementsByName("claimantEmails")),
        defendantEmailValues = slice.call(document.getElementsByName("defendantEmails"));
    
    var k = defendantEmailValues.length;
    for(var i=0; i<claimantEmailValues.length;i++){
            defendantEmailValues[k++] = claimantEmailValues[i];
    }
    

    It’s likely that the behaviour of previous Firefox versions was incorrectly allowing items to be added to HTMLCollection instances and the bug was only just fixed in Firefox 10.

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

Sidebar

Related Questions

I used the code from http://www.rgagnon.com/javadetails/java-0580.html to get Motherboard Id, but the result is
I have a JLabel which has an e-mail address in it. I used HTML
In the past people used to wrap HTML comment tags around blocks of JavaScript
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I am mostly following this page: http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html I used this command to create the
Can Html Agility Pack be used to parse an html string fragment? Such As:
I have used this in my HTML: <q> Hai How r u </q> Which
I have used extension methods to extend html helpers to make an RSS repeater:
I have used fieldset tag in HTML page, whereby i need some text to
I used to be able to do this to create an exported HTML page

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.