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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:24:18+00:00 2026-05-17T19:24:18+00:00

OK, so here was my original problem. You don’t have to read it but

  • 0

OK, so here was my original problem. You don’t have to read it but in case it helps: Firefox thinks <fieldset> is a form element; Chrome doesn't

Basically, Firefox and IE count the fieldset in my HTML as an element in my array, and that screws everything up. But Google Chrome does not count the fieldset as an array element. I’m trying to solve the problem by setting the new array one way if the browser counts the fieldset, and setting it a different way if it does. Here’s my code. I think the problem is with the if statement.

var $ = function (id) { return document.getElementById(id); }

function check() {
var x = $("myForm");

var user = new Array();
var type = x.elements[0].type;
    if (x.elements[0].nodeName=="fieldset") {
    user[0] = x.elements[1].value;
    user[1] = x.elements[3].value;
    user[2] = x.elements[5].value;
    user[3] = x.elements[2].value;
    user[4] = x.elements[4].value;
    user[5] = x.elements[6].value;
} else {
    user[0] = x.elements[0].value;
    user[1] = x.elements[2].value;
    user[2] = x.elements[4].value;
    user[3] = x.elements[1].value;
    user[4] = x.elements[3].value;
    user[5] = x.elements[5].value;
}

var answers = new Array();
answers[0] = "sample1";
answers[1] = "sample2";
answers[2] = "sample3";
answers[3] = "sample4";
answers[4] = "sample5";
answers[5] = "sample6";

var display = new Array();
for (var i=0;i<6;i++) {
    if (user[i] == "") {
        display[i] = "You entered nothing.";
        }
    else if (user[i] == answers[i]) {
        display[i] = "Correct!";
        }
    else {
        display[i] = "Wrong. The correct answer is \"" + answers[i] + "\".";
        }
    }
alert(display[0] + "\n" + display[1] + "\n" + display[2] + "\n" + display[3] + "\n" + display[4] + "\n" + display[5]);
}
  • 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-17T19:24:19+00:00Added an answer on May 17, 2026 at 7:24 pm

    The problem you were having is mainly because nodeName usually returns uppercase text (depending on the browser), and you are comparing it with lowercase fieldset. To make it consistent you should use string’s toLowerCase function.

    About the conditionals: I think a more elegant way would be to create a new filtered array without <fieldset> and submit button.

    Finally, the way you’re creating your arrays involves a little bit too much typing.

    I suggest you using literal notation for creating Arrays and Objects.

    [Demo] (click preview)

    function $(id) { return document.getElementById(id); }
    
    var filtered = [];
    var elements = $("myForm").elements;
    var len = elements.length;
    
    // opt out fieldsets and submit buttons
    for (var i = 0; i < len; i++) {
      var el = elements[i];
      if (el.nodeName.toLowerCase() != "fieldset" && el.type != "submit") {
        filtered.push(el);
      }
    }
    
    // specify an order (of indices)
    var user = [1, 3, 5, 2, 4, 6];
    
    // then replace numbers with element 
    // values  from the filtered array
    for (var i = 0; i < user.length; i++) {
      user[i] = filtered[ user[i] ].value;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem I don't understand regarding UIViews and Core Animation. Here's what
Let's say I have some original text: here is some text that has a
You can see my posted code here . My original problem was more or
I have encountered a problem when simulation transparency in OpenGL. Here is the scenario:
Refer original post here for a reference to the original issue. What plugin should
here is the original code: public static int getInt () { Scanner in =
Ok, here was my original question; Table one contains ID|Name 1 Mary 2 John
This question is sort of a follow-up to my original question here . Let's
I'm trying to parallelize a convolution function in C. Here's the original function which
My original question can be found here , for which I've gotten some great

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.