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

The Archive Base Latest Questions

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

I have done some searching but I am very new to JavaScript and jQuery

  • 0

I have done some searching but I am very new to JavaScript and jQuery and can’t seem to figure out how to go about this (or if it is even possible). Basically, I have two select menus and an associated value with each choice that is NOT the same as the text but the same between selects:

<select id="day1Breakfast">
<option value="">Select One</option>
<option value="bec">Bacon Egg and Cheese</option>
<option value="muf">Muffin</option>
<option value="bag">Bagel</option>
</select>

<select id="day2Breakfast">
<option value="">Select One</option>
<option value="bec">Bacon Egg and Cheese</option>
<option value="muf">Muffin</option>
<option value="bag">Bagel</option>
</select> 

What I need to do is populate another div with the text of the choice based on the SELECT ID and OPTION VALUE. For instance, if someone selected “Muffin” from the day2Breakfast SELECT, I would want to alert(“You chose Muffin for Day 2”). I understand that I can use this to find the text from a div with some ID:

document.getElementById("day1Breakfast").text()

But that will return “Bacon Egg and CheeseMuffinBagel”. I need only retrieve the text associated with the specific SELECT ID and OPTION VALUE.

Thank you very much!

  • 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-17T04:03:07+00:00Added an answer on June 17, 2026 at 4:03 am

    You’re looking for the elements .value (in vanilla JavaScript), and is .val() in jQuery. Further, to get the text of the selected value, simply request all option:selected within the element:

    // Event delegation on all select elements
    $("select").on("change", function (e) {
      // When a select changes, find the selection option
      // Also, get the ID of the select element that changed
      var selected = $(this).find("option:selected"),
          fromElem = $(this).prop("id");
      // Output the new selected text, value, and ID of affected select
      console.log( selected.text(), selected.val(), fromElem );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done some searching around but have not been able to figure out
I have done some stuff in jQuery and Javascript before, but unfortunately I am
i have done some code in jquery but where i commented in this bellow
Using SilverStripe 2.4.7. I've done some searching but I can't seem to be able
Does the erlang TCP/IP library have some limitations? I've done some searching but can't
so i have done some searching and found this issue is known but none
I have done some searching but really haven't found what I'm looking for. What
I've done some searching around but I have a specific question on SQL Injection
Have done some searching through Stack Exchange answered questions but have been unable to
I have done some looking and I found this: http://www.codeproject.com/Articles/14439/The-ScrollableListBox-Custom-Control-for-ASP-NET-2 but to me it

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.