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

  • SEARCH
  • Home
  • 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 8338083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:09+00:00 2026-06-09T04:29:09+00:00

In this thread , it is described how you can fetch the selected value

  • 0

In this thread, it is described how you can fetch the selected value from a drop down box using JavaScript. I’ve been trying to follow the instructions in that thread, but haven’t been able to get it working.

Here’s a minimal (non-working) example of what I’m trying to do. The code should print the value of the second option from the drop down box, but instead I get the following error in the Chrome’s JavaScript console Uncaught TypeError: Cannot read property 'options' of null on row 11 (that is, when I define my second variable).

<html>
  <body>
    <select name='a_drop_down_box'>
        <option value='1'>One</option>
        <option value='2' selected='selected'>Two</option>
        <option value='3'>Three</option>
    </select>
    <p id='message'></p>
    <script type="text/javascript">
        var test = document.getElementById("a_drop_down_box");
        var testValue = test.options[test.selectedIndex].value;
        document.getElementById('message').innerHTML=testValue;
    </script>
  </body>
</html>
  • 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-09T04:29:11+00:00Added an answer on June 9, 2026 at 4:29 am
    document.getElementById("a_drop_down_box");
    

    Did you notice that you haven’t defined an id for the select item?

    The name attribute is used to identify the form element for requests send using the form. You should use an id to retrieve it from the dom.

    Alternatively if your select resides inside a form, you could use this:

    document.getElementById("myForm").elements["a_drop_down_box"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to accomplish something similar to what was described in this thread:
I have a situation like the one described in this thread: How can i
I've been reading and trying to use the method proposed in this thread: How
The algorithm is described in this paper: Thread Scheduling for Multiprogrammed Multiprocessors . Briefly,
I'm using an invocation described in this question: Synchronization accross threads / atomic checks?
I am experiencing the same problem described in this thread . I'm wondering if
As far as I can understand from the java.lang.Thread docs, and from other questions
I have been trying various implementations to make this work, and have searched StackOverflow
This thread didn't helped me. If I use $class_vars = get_class_vars(get_class($this)); foreach ($class_vars as
Is this thread safe? private static bool close_thread_running = false; public static void StartBrowserCleaning()

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.