About 1,500,000 results
Open links in new tab
  1. A select list in JavaScript refers to an HTML <select> element that allows users to choose one or more options from a dropdown. Each <option> inside the <select> has a value (used in form submission) and text (displayed to the user) .

    You can access and manipulate select lists using the DOM API, retrieve the selected value or text, and even populate them dynamically.

    Example: Getting Selected Value and Text

    <select id="ddlViewBy">
    <option value="1">Option 1</option>
    <option value="2" selected>Option 2</option>
    <option value="3">Option 3</option>
    </select>

    <script>
    const select = document.getElementById("ddlViewBy");

    // Get selected value
    const value = select.value;

    // Get selected text
    const text = select.options[select.selectedIndex].text;

    console.log("Value:", value); // "2"
    console.log("Text:", text); // "Option 2"
    </script>
    Copied!

    Here, .value returns the value attribute of the selected option, while .options[.selectedIndex].text returns the display text .

    Feedback
  2. Get selected value in dropdown list using JavaScript

    Jul 6, 2009 · How do I get the selected value from a dropdown list using JavaScript? <form> <select id="ddlViewBy"> <option value="1">test1</option> <option value="2" sel...

    Code sample

    var e = document.getElementById("ddlViewBy");
    var strUser = e.options[e.selectedIndex].value;
  3. HTML DOM Select value Property - W3Schools

    Description The value property sets or returns the value of the selected option in a drop-down list.

  4. People also ask
  5. 3 Ways To Get The Selected Value in a Dropdown List Using …

      1. Using the value Property. The value property of a select element returns the …
      2. Using the selectedIndex Property. The selectedIndex property of a select …
      3. Using the options Collection. The options property of a select element returns …
  6. JavaScript select Element

    • To interact with <select> element in JavaScript, you use the HTMLSelectElementtype. The HTMLSelectElementtype has the following useful properties: 1. selectedIndex – returns the zero-based index of the selected option. The selectedIndex is -1 if no option is selected. If the <select> element allows multiple selections, the selectedIndex returns the...
    See more on javascripttutorial.net
  7. How to Get the Value of Selected Option in a Select …

    You can either select text or find the position of it in a drop-down list by using the option:selected attribute or the val () method in jQuery. The val () …

  8. HTMLSelectElement: value property - Web APIs | MDN

    May 30, 2024 · The HTMLSelectElement.value property contains the value of the first selected <option> element associated with this <select> element. This property can also be set directly, …

  9. How to get the value of a form element - JavaScript

    To get the index of the selected option in the JavaScript options array of the select element, we can use the selectedIndex property of the select element object: We can now use this index to …

  10. How to Retrieve Selected Values from JavaScript Dropdowns

    Nov 2, 2023 · In JavaScript, there are a few different ways to get the selected value (s) from a drop-down menu. This guide will demonstrate the main methods for retrieving user-selected …

  11. How to Get Selected Value in Dropdown List using JavaScript?

    Jul 11, 2025 · Learn how to get the selected value from a dropdown list using JavaScript with clear examples and code snippets. Ideal for beginners and web developers.

  12. JavaScript: How to Get the Value of a Select or Dropdown List

    Nov 13, 2019 · Getting the value of a select in HTML is a fairly recurring question. Learn how to return the value and text of a dropdown list using pure JavaScript or jQuery.

    • Udemy
      www.udemy.com
      About our ads

      Learn JavaScript on Udemy - Udemy Online Classes

      SponsoredWhether you're learning for a promotion or a passion, Udemy has the course for you. Empower your future with limitless learning. Discover all the courses Udemy has to offer.
      Site visitors: Over 1M in the past month

      Learn in 75 Languages · Subscribe to Learning · Join 69M+ Learners

      Courses: Development, IT & Software, Business, Design, Office Productivity