How to get Values from HTML Input Array using JavaScript? Last Updated : 09 Jan, 2025 Summarize Comments Improve Suggest changes Share 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 Value by Class Name 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 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 Like