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 139573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:27:34+00:00 2026-05-11T07:27:34+00:00

In the following: <select id=test> <option value=1>Test One</option> <option value=2>Test Two</option> </select> How can

  • 0

In the following:

<select id='test'>     <option value='1'>Test One</option>     <option value='2'>Test Two</option> </select> 

How can I get the text of the selected option (i.e. ‘Test One’ or ‘Test Two’) using JavaScript

document.getElementsById('test').selectedValue returns 1 or 2, what property returns the text of the selected option?

  • 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. 2026-05-11T07:27:34+00:00Added an answer on May 11, 2026 at 7:27 am
    function getSelectedText(elementId) {     var elt = document.getElementById(elementId);      if (elt.selectedIndex == -1)         return null;      return elt.options[elt.selectedIndex].text; }  var text = getSelectedText('test'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following filteringselect: <select name=v dojoType=dijit.form.FilteringSelect valueList=v id=v value=0><option value=></option><option value=0>0-test</option><option value=1>1-test2/option><option value=2>2-test3</option><option
Why isn't the following piece of code working in IE8? <select> <option onclick=javascript: alert('test');>5</option>
I have the following HTML: <select id=testMe name=test multiple=multiple size=5 style=width:270px> <option value=test1>test1</option> <option
I have the following code: <select> <option value=blablabla>Test</option> <!-- ... --> </select> But I
I have the following drop-down: <select id=#test> <option value=1>1</option> <option value=2>2</option> <option value=3>3</option> </select>
I have a dropdownlist: <select id=ContentList name=ContentList> <option value=>Please Select</option> <option value=TEST_TOP>TEST TOP</option> </select>
I have the following html <div id=active-el> <select id=select-drop> <option value=1>1</option> <option value=2>2</option> <option
I have the following select element with an onchange event. <select name=ftest onchange=alert('test');> <option
I am trying to return the text for selected value from a select_list using
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT

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.