Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:05:25+00:00 2026-06-17T16:05:25+00:00

Possible Duplicate: How to get the selected value of dropdownlist using JavaScript? javascript selected

  • 0

Possible Duplicate:
How to get the selected value of dropdownlist using JavaScript?
javascript selected value

I have a drop down list for quantities, like this:

<select id="Quantity" name="Quantity" class="quantity_select">
    <option id="1" selected="selected" value="1">1</option>
    <option id="2" value="2">2</option>
    <option id="3" value="3">3</option>
</select>

I need to use javascript to find the value of the currently selected quantity. When I select e.g. option 2, the selected=”selected” doesn’t change to the new option. How can I use the DOM to get the current selected quantity?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:05:25+00:00Added an answer on June 17, 2026 at 4:05 pm

    Option 1

    HTML

    <select id="Quantity" name="Quantity" 
            class="quantity_select" onchange="SetValue(this.value)>
        <option id="1" selected="selected" value="1">1</option>
        <option id="2" value="2">2</option>
        <option id="3" value="3">3</option>
    </select>
    

    JavaScript

    function SetValue(val) {
        alert(val); // This will be the selected value in the drop down
    }
    

    Option 2

    If you already have JS in place, and don’t want to use option 1, you can simply get the value with getElementById():

    var ddl = document.getElementById('Quantity');
    var val = ddl.options[ddl.selectedIndex].value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to get the selected value of dropdownlist using JavaScript? I have
Possible Duplicate: How to get the selected value of dropdownlist using JavaScript? How to
Possible Duplicate: How can I get drop down menu value still selected after form
Possible Duplicate: jQuery get selected text from dropdownlist <select id=id_deals name=deals multiple=multiple> <option value=1>deal
Possible Duplicate: Get selected element's outer HTML I have this code : <html> <head></head>
Possible Duplicate: Get Class List for Element with jQuery If I have something like
Possible Duplicate: Get a list of dates between two dates This is my sql:
Possible Duplicate: Get Client IP using just Javascript? I know PhP can know your
Possible Duplicate: PHP - PRE-select drop down option I have a situation in my
Possible Duplicate: jQuery: get the file name selected from <input type=file /> I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.