How to Get Selected Value in Dropdown List using JavaScript? Last Updated : 08 Oct, 2024 Comments Improve Suggest changes Like Article Like Report 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 a DropdownTo create a dropdown list, you will use the following HTML structure:<select id="dropdown-id"> <option value="html">HTML</option> <option value="css">CSS</option> <option value="js">JavaScript</option> </select>This syntax create a dropdown list with three options HTML, CSS, and JavaScript. Each options has an individual attribute (for example - value="html"). To create a dropdown list, You can refer this article How to create the dropdown menu?. Get the Selected Value from Dropdown using DOM value PropertyTo get the selected value from dropdown list, we need to use JavaScript. The HTML DOM value property is used to get the selected value of a dropdown list item.SyntaxselectedElement.value;Example: The below code uses the value property to get the value of the selected dropdown item. HTML <!DOCTYPE html> <html> <head> <title> Get Selected Value in Dropdown List using JavaScript </title> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <p> <b>How to get selected value in dropdown list using JavaScript?</b> </p> <label>Select one from the given options:</label> <select id="select1"> <option value="free">Free</option> <option value="basic">Basic</option> <option value="premium">Premium</option> </select> <p> The value of the option selected is: <span class="output"></span> </p> <button onclick="getOption()"> Check option </button> <script> function getOption() { selectElement = document.querySelector('#select1'); output = selectElement.value; document.querySelector('.output').textContent = output; } </script> </body> </html> Outputvalue propertyGet the Selected Value from Dropdown using DOM selectedIndex PropertyThe selectedIndex property gives you the index (position) of the currently selected option in the dropdown list. This index starts at 0. If no option is selected, it returns -1. You can then use this index to find the value of the selected option.SyntaxSelectElement.options[selectedElement.selectedIndex].value;Example: The eblow example implements the selectedIndex property to get the value of selected dropdown item. HTML <!DOCTYPE html> <html> <head> <title> Get Selected Value in Dropdown List using JavaScript </title> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <p> <b>How to get selected value in dropdown list using JavaScript?</b> </p> <label>Select one from the given options:</label> <select id="select1"> <option value="free">Free</option> <option value="basic">Basic</option> <option value="premium">Premium</option> </select> <p> The value of the option selected is: <span class="output"></span> </p> <button onclick="getOption()"> Check option </button> <script> function getOption() { selectElement = document.querySelector('#select1'); output = selectElement.options [selectElement.selectedIndex].value; document.querySelector('.output').textContent = output; } </script> </body> </html> OutputSelectedIndex property with option property Comment More infoAdvertise with us Next Article How to Get Selected Value in Dropdown List using JavaScript? sayantanm19 Follow Improve Article Tags : JavaScript Web Technologies JQuery JavaScript-Questions Similar Reads How to Create a Dropdown List with Array Values using JavaScript? To add elements to the select element from the JavaScript array, We can also get selected values in the dropdown list using JavaScript. Here we will populate the dropdown list with an array.Below are the methods to create a dropdown list with array values:Table of ContentUsing Pure JavaScriptUsing j 2 min read How to get the text of option tag by value using JavaScript ? To get the text of the option tag by value using JavaScript, we have multiple approaches. we are going to learn how to get the text of the option tag by value using JavaScript. These are the following approaches that are discussed below: Table of Content Using value PropertyUsing Object.values() Met 3 min read How to get selected option from Dropdown in jQuery ? In this article, we learn how to get the selected option from the dropdown list. This article requires some familiarity with HTML, CSS, JavaScript, and jQuery. We can solve this challenge by using the jQuery val() method. The val() method in jQuery is used to set or return the value of an attribute 2 min read How to change Selected Value of a Drop-Down List using jQuery? We will change the default selected value of the dropdown using jQuery. In an HTML select tag, the default selected value is the value given to the first option tag. With jQuery, it is easy to change the selected value from a drop-down list. Below are the methods to change the selected value of a dr 3 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 Select Value from DropDown using Java Selenium Webdriver? In web Automation testing, the common task is Selecting the Dropdowns. Selenium Webdriver mainly used for Interacting to the Web-Elements. Selecting the Web-Elements from the dropdowns is a needed for the interaction to the browser.In these guide we will going through the process of selecting the dr 2 min read How to get selected text from a drop-down list using jQuery? In this article, we will learn how we can get the text of the selected option in a select tag using jQuery. There are two ways in jQuery that we can use to accomplish this task. Table of Content Using the val() method By using option:selected selector and text() method togehterUsing the val() method 2 min read How To Get Select Element's Value In react-bootstrap? React-Bootstrap is a popular library that provides Bootstrap-styled React components. One of the most commonly used form elements is the <select> dropdown, which allows users to choose from a list of options. In this article, weâll explore how to get the value of a select element in a React-Bo 2 min read How to select first element in the drop-down list using jQuery ? Given a drop-down list containing options elements, the task is to get the first element of the select element using JQuery. Approach 1: Select the first element of <select> element using the jQuery selector.Use the prop() method to get access to properties of that particular element.Change th 2 min read How To Create A Cascading Dropdown List Using JavaScript? The Cascading dropdown lists are used to display options in a secondary dropdown based on the selection made in a primary dropdown. This is useful in forms where users need to select categories or locations in the hierarchical manner. For example: selecting a country might reveal states or provinces 3 min read Like