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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:21:22+00:00 2026-06-11T04:21:22+00:00

How can I create a dynamic array in an array with dynamic keys and

  • 0

How can I create a dynamic array in an array with dynamic keys and dynamic values using javascript?

For an example, check below what I’d like:

Studentslist  
  Student Info 1
      "name" => "varun",
      "age" => "24"

  Student Info 2
      "name" => "Kumar",
      "age" => "25"

Add More Info About This Question

I have a radio buttone like this

<input type="radio" value="student1" id="student1" name="student1group1"/>
<input type="radio" value="student2" id="student1" name="student1group1"/>

<input type="radio" value="student3" id="student2" name="student1group2"/>
<input type="radio" value="student4" id="student2" name="student1group2"/>

I need to setup a array in array when any radio button is clicked for eg in student1group1 any of the 2 radio buttons is clicked i need to get the array like below

Studentslist  
  Student Info 1
          "name" => clicked value of the radio button,
  • 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-06-11T04:21:24+00:00Added an answer on June 11, 2026 at 4:21 am

    You can try this

    var Studentslist  = [];
    
    var student = {name:"varun", age:24 }
    
    Studentslist.push(student);
    
    student = {name:"Kumar", age:25};
    
    Studentslist.push(student);
    
    student = {name:"Varun Kumar", age:26}
    
    Studentslist.push(student);
    

    for getting student detail you can try.

    for(var x in Studentslist)
    {
        alert(x.name);
    }
    

    with radio buttons, you can try

    <input type="radio" value="student1" id="student1" name="student1group1"/>
    <input type="radio" value="student2" id="student1" name="student1group1"/>
    
    <input type="radio" value="student3" id="student2" name="student1group2"/>
    <input type="radio" value="student4" id="student2" name="student1group2"/>
    

    javascript :

    var Studentslist  = [];
    
    window.onload = function(){
        var allinputs = document.getElementsByTagName("input");
        for(var x in allinputs)
        {
           if(x.type == "radio")
           {
              x.onclick = function() {
                 if(this.checked){
                   var student = {name: x.value };
                   Studentslist.push(student);
                 }
              }
           }
        }
    }
    

    You can call this method to alert.

    function CheckStudentDetails
    {
        for(var x =0;x<Studentslist.length; x++)
        {
            for(var y in Studentslist[x])
            {
                 alert(Studentslist[x][y]);
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can create and use dynamic two dimensional array in Fortran (in 77 standard).
Is there a way to create a dynamic array of strings on Javascript? What
I'd like to be able to somehow create a dynamic array that would still
I would like to create a dynamic array which store permutation sequence, such that
i am trying to create array like in the example i wrote above: $arr=array('roi
how can I create a dynamic lambda expression to pass to use in my
Most things are dynamic in SSRS i.e you can create a custom expression for
How I can implement dynamic Jtree, which shows created instances of clases? For example,
I can create database manually by going to cpanel. But I'd like to create
Can I initialize a constant dynamic array of arrays? If: type tNamePair = array[1..2]

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.