How to get all checked values of checkbox in JavaScript ? Last Updated : 01 Aug, 2024 Comments Improve Suggest changes Like Article Like Report A checkbox is a selection box that enables users to pick true or false in a binary manner by checking or unchecking it. When a checkbox is checked, it shows that the value has been chosen by the user, and when a checkbox is not checked indicates false which denotes that the user has not chosen the value. In this article, we will discuss how we can get all the checked values from the selected checkbox using HTML and javascript.Syntax:<input type="checkbox" id="" value="on" name="">Approachcreate an HTML document with a green-themed header ("GeeksforGeeks").Add Checkboxes for HP, DELL, MAC, and ASUS laptops with the same name ("laptop").The header color is set to green using inline CSS.Checkboxes allow users to select multiple laptop brands.getValue() function triggered by a button click.Iterates through checkboxes build a result string of selected values.The result is displayed dynamically using document.write() a paragraph ("<p>") tag.Example: In this example, we will create four checkboxes but with the requirement that the user checks only two checkboxes between them, then we will fetch the value of marked checkboxes. HTML <!DOCTYPE html> <html lang="en"> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <input type="checkbox" name="laptop" value="HP">HP laptop<br> <input type="checkbox" name="laptop" value="DELL">DELL laptop<br> <input type="checkbox" name="laptop" value="MAC">MAC laptop<br> <input type="checkbox" name="laptop" value="ASUS">ASUS laptop<br> <button onclick="getValue()"> Get Value </button> <script> function getValue() { let checkboxes = document.getElementsByName('laptop'); let result = ""; for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { result += checkboxes[i].value + " " + " Laptop, "; } } document.write("<p> You have selected : " + result + "</p>"); } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to get all checked values of checkbox in JavaScript ? iamgaurav Follow Improve Article Tags : HTML HTML-Questions JavaScript-Questions Similar Reads How to Create a Select All Checkbox in JavaScript ? In web apps with lots of checkboxes, a "Select All" checkbox is useful. It lets users check or uncheck all checkboxes at once, making things quicker. This feature can be implemented in various ways, such as utilizing JavaScript and JQuery to incorporate a "Select All" checkbox. This enhances the app 2 min read How to Validate Checkbox in JavaScript? Validation of checkboxes is important to make sure that users select the required options, enhancing data accuracy and user experience. Table of Content Using a LoopUsing FormData ObjectUsing a LoopIn this approach, we are using a loop to iterate through each checkbox in the form. We check if any ch 3 min read How to use javascript function in check box? Checkboxes are used for instances where a user may wish to select multiple options, such as in the instance of a "check all that apply" question, in forms. HTML Checkboxes Selected. A checkbox element can be placed onto a web page in a pre-checked fashion by setting the checked attribute with a "yes 2 min read Get the value of a checkbox in Flask The checkbox is a typical widget with selected options within a list by a user. They are employed in web forms whereby they are applied in the selection of preferences, settings, or a survey. Here in this article, we will see how to add the checkboxes in the Flask application right from the installa 5 min read How to Check/Uncheck the checkbox using JavaScript ? To check and uncheck the checkbox using JavaScript we can use the onclick event to toggle the checkbox value. We can also check or uncheck all the checkboxes on loading the webpage using JavaScript onload function.In this article, we will learn how to check/uncheck the checkbox using JavaScript. As 3 min read How To Get Multiple Checkbox Values In ReactJS? Handling checkboxes in ReactJS becomes important when creating forms or managing user input. If you need to select multiple options, we can do it by implementing multiple checkboxes. In this article, we'll explore how to get the values of multiple checkboxes in ReactJS, manage the state, and display 4 min read How to get Values from HTML Input Array using JavaScript? 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 2 min read How to Check whether a Checkbox is Checked in jQuery? We can use prop() and is() methods to check whether a checkbox is checked in jQuery. A checkbox is a user interface element that allows users to select or deselect an option. 1. Using prop() MethodThis prop() method provides a simple way to track down the status of checkboxes. It works well in every 2 min read How to find all checkbox inputs using jQuery ? The task is to find all the checkbox input using jQuery. Checkboxes are the square boxes that are ticked when activated, and it is used to select one or more number of choices. Method and Selectors used: :checkbox: This selector is used to select the input element with type = checkbox. .wrap(): This 2 min read How to get the total number of checkboxes in a page using Selenium? In the world of automated testing, Selenium is a powerful tool that helps automate web browsers. One common task during web testing is determining the number of specific elements on a page, such as checkboxes. This can be useful for validating the presence and quantity of checkboxes on a form or any 3 min read Like