How to get Values from HTML Input Array using JavaScript? Last Updated : 09 Jan, 2025 Comments Improve Suggest changes Like Article Like Report This problem can be solved by using input tags having the same "name" attribute value that can group multiple values stored under one name which could later be accessed by using that name. Syntaxlet input = document.getElementsByName('array[]');What is an Input Array in HTML?An "input array" in HTML typically refers to form elements that share the same name attribute. These could be:Checkboxes: Allow users to select multiple options.Radio Buttons: Allow users to select only one option from a group.Select Dropdowns: Though they don't have the same name, they can return multiple selected options.Using Document.getElementsByName() MethodIt returns all the values stored under a particular name thus making the input variable an array indexed from 0 to the number of inputs. The method document.getElementById().innerHTML is used to change the inner HTML of the selected Id. So in this way, we can access the input values and convert them into the array and access it as you like. html <body style="text-align: center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h3 id="po">Input Array Elements</h3> <form class="" action="index.html" method="post"> <input type="text" name="array[]" value="" /><br> <input type="text" name="array[]" value="" /><br> <input type="text" name="array[]" value="" /><br> <input type="text" name="array[]" value="" /><br> <input type="text" name="array[]" value="" /><br> <button type="button" name="button" onclick="Geeks()"> Submit </button> </form> <br> <p id="par"></p> <script type="text/javascript"> let k = "The respective values are :"; function Geeks() { let input = document.getElementsByName('array[]'); for (let i = 0; i < input.length; i++) { let a = input[i]; k = k + "array[" + i + "].value= " + a.value + " "; } document.getElementById("par").innerHTML = k; document.getElementById("po").innerHTML = "Output"; } </script> </body> OutputJavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples. Comment More infoAdvertise with us Next Article How to get Values from HTML Input Array using JavaScript? S shivanshsaxena1 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to get Values from Specific Objects an Array in JavaScript ? In JavaScript, an array is a data structure that can hold a collection of values, which can be of any data type, including numbers, strings, and objects. When an array contains objects, it is called an array of objects. Table of Content Using the forEach() methodUsing the map() methodUsing the filte 2 min read How to get hidden field array values in javascript? To retrieve values from hidden fields in JavaScript, you can use methods like querySelectorAll or getElementsByName to select these elements and extract their values. This can be useful for gathering data that isn't directly visible on a web page but still needs to be accessed or processed.Example U 2 min read How to specify the value of an input element using HTML ? In this article, we will set the value of an input element using HTML. The value attribute for <input> element in HTML is used to specify the initial value of the input element. It has different meaning for different input type: The âbuttonâ, âresetâ and âsubmitâ property specifies the text on 1 min read How to get form input value using AngularJS ? Given a form element and the task is to get the form values input by the user with the help of AngularJS.Approach: We are storing the data in the JSON object after the user enters it in the input element with the help of the Angular.copy(object) method. After that, data from the JSON object can be a 2 min read How to Get Value by Class Name using JavaScript ? This article will show you how to use JavaScript to get value by class name. To get the value of an element by its class name in JavaScript, you can use the getElementsByClassName() method. This method returns an array-like object of all elements with the specified class name. You can then access th 2 min read Get the Value of Text Input Field using JavaScript Getting the value of a text input field using JavaScript refers to accessing the current content entered by a user in an input element, such as <input> or <textarea>, by utilizing the value property. This allows for dynamic interaction and data manipulation in web forms.Syntax inputField 2 min read How to get form data using JavaScript/jQuery? The serializeArray() method creates an array of objects (name and value) by serializing form values. This method can be used to get the form data. Syntax: $(selector).serializeArray() Parameter: It does not accept any parameter. Return Value: It returns all the value that is inside the inputs fields 1 min read How to Get Selected Value in Dropdown List using JavaScript? A dropdown list is an HTML element that allows users to select one option from a list of options. The <select> and <option> tags are used to create dropdown lists in HTML. In this article, we will see how to get selected value from dropdown list using JavaScript.Basic HTML Structure for 2 min read How to Convert HTML Form Field Values to JSON Object using JavaScript? Storing HTML input data into JSON format using JavaScript can be useful in various web development scenarios such as form submissions, data processing, and AJAX requests. Here we will explore how to convert the HTML form input data into the JSON format using JavaScript. ApproachThe HTML file contain 2 min read How to Get the Value of an Input Text Box using jQuery? When working with forms or interactive web pages, sometimes need to get the values entered into the input fields. This article provide a complete guide on how to get the value o an input text box using jQuery. Below are the different approaches to get the value of an input text box using jQuery:Get 2 min read Like