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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:41:20+00:00 2026-05-25T18:41:20+00:00

Can anyone give me a sample/example of JavaScript with a multidimensional array of inputs?

  • 0

Can anyone give me a sample/example of JavaScript with a multidimensional array of inputs? Hope you could help because I’m still new to the JavaScript.

Like when you input 2 rows and 2 columns the output of it will be 2 rows of input and 2 columns of input.

Like this:

[input][input]                
[input][input]
  • 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-25T18:41:20+00:00Added an answer on May 25, 2026 at 6:41 pm
    var numeric = [
        ['input1','input2'],
        ['input3','input4']
    ];
    numeric[0][0] == 'input1';
    numeric[0][1] == 'input2';
    numeric[1][0] == 'input3';
    numeric[1][1] == 'input4';
    
    var obj = {
        'row1' : {
            'key1' : 'input1',
            'key2' : 'input2'
        },
        'row2' : {
            'key3' : 'input3',
            'key4' : 'input4'
        }
    };
    obj.row1.key1 == 'input1';
    obj.row1.key2 == 'input2';
    obj.row2.key1 == 'input3';
    obj.row2.key2 == 'input4';
    
    var mixed = {
        'row1' : ['input1', 'inpu2'],
        'row2' : ['input3', 'input4']
    };
    mixed.row1[0] == 'input1';
    mixed.row1[1] == 'input2';
    mixed.row2[0] == 'input3';
    mixed.row2[1] == 'input4';
    

    http://jsfiddle.net/z4Un3/

    And if you’re wanting to store DOM elements:

    var inputs = [
        [
            document.createElement('input'),
            document.createElement('input')
        ],
        [
            document.createElement('input'),
            document.createElement('input')
        ]
    ];
    inputs[0][0].id = 'input1';
    inputs[0][1].id = 'input2';
    inputs[1][0].id = 'input3';
    inputs[1][1].id = 'input4';
    

    Not real sure how useful the above is until you attach the elements. The below may be more what you’re looking for:

    <input text="text" id="input5"/>
    <input text="text" id="input6"/>
    <input text="text" id="input7"/>
    <input text="text" id="input8"/>    
    var els = [
        [
            document.getElementById('input5'),
            document.getElementById('input6')
        ],
        [
            document.getElementById('input7'),
            document.getElementById('input8')
        ]
    ];    
    els[0][0].id = 'input5';
    els[0][1].id = 'input6';
    els[1][0].id = 'input7';
    els[1][1].id = 'input8';
    

    http://jsfiddle.net/z4Un3/3/

    Or, maybe this:

    <input text="text" value="4" id="input5"/>
    <input text="text" value="4" id="input6"/>
    <br/>
    <input text="text" value="2" id="input7"/>
    <input text="text" value="4" id="input8"/>
    
    var els = [
        [
            document.getElementById('input5'),
            document.getElementById('input6')
        ],
        [
            document.getElementById('input7'),
            document.getElementById('input8')
        ]
    ];
    
    var result = [];
    
    for (var i = 0; i < els.length; i++) {
        result[result.length] = els[0][i].value - els[1][i].value;
    }
    

    Which gives:

    [2, 0]
    

    In the console. If you want to output that to text, you can result.join(' ');, which would give you 2 0.

    http://jsfiddle.net/z4Un3/6/

    EDIT

    And a working demonstration:

    <input text="text" value="4" id="input5"/>
    <input text="text" value="4" id="input6"/>
    <br/>
    <input text="text" value="2" id="input7"/>
    <input text="text" value="4" id="input8"/>
    <br/>
    <input type="button" value="Add" onclick="add()"/>
    
    // This would just go in a script block in the head
    function add() {
        var els = [
            [
                document.getElementById('input5'),
                document.getElementById('input6')
            ],
            [
                document.getElementById('input7'),
                document.getElementById('input8')
            ]
        ];
    
        var result = [];
    
        for (var i = 0; i < els.length; i++) {
            result[result.length] = parseInt(els[0][i].value) - parseInt(els[1][i].value);
        }
    
        alert(result.join(' '));
    }
    

    http://jsfiddle.net/z4Un3/8/

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

Sidebar

Related Questions

Can anyone give me an example of how I can consume the following web
Guys, can anyone give a simple practical example of LockSupport & AbstractQueuedSynchronizer use? Example
Can anyone give a simple example of a DB transaction using an Intentional Shared
I am a beginner in web/javascript programming and wonder if anyone can give me
Can anyone give me an example of successful non-programmer, 5GL (not that I am
Can anyone give an example or a link to an example which uses __builtin_prefetch
For instance, like Font. Can anyone give a very simple example? Maybe just a
Can anyone give me a complete list of string manipulation function in Microsoft SQL
Can anyone give me pointers to good books or web sites that teach how
Can anyone give me details of runtime error 3734 in Access vba. For reference

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.