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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:25:20+00:00 2026-05-19T11:25:20+00:00

I have the following selection : var squad_name= $(#squad option:selected).text(); and the HTML behind

  • 0

I have the following selection :

var squad_name= $("#squad option:selected").text();

and the HTML behind looks like this:

<div id="squad">
    <label>Squad Type:</label>
    <select id="choosesquad">
        <option value ="0">Choose squad</option>
    </select>
    <input id="setsquad" type="button" value="Set"/><br>

    <div id="unitdiv">
    <label>Choose Unit:</label>
    <select id="chooseunit" class="unit">
        <option value ="0">Choose unit</option>
    </select><br>
    <label>Number of units:</label>
    <select id="number" class="unit">
        <option value="0">0</option>      
    </select><br>
</div>

for some reason after this selection the squad_name=Choseen Squad Choose unit 0

I just can’t figure out: what I am doing wrong?

  • 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-05-19T11:25:21+00:00Added an answer on May 19, 2026 at 11:25 am

    This is happening because you’re selecting all <option> tags in #squad, which has 3 <select> tags with 3 :selected <option> tags

    $("#squad option:selected") is aggregating each selected option from #choosesquad, #chooseunit, and #number

    from the sounds of it you need to use this:

    var squad_name = $("#choosesquad option:selected").text();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following, very simple html page: <html> <head> <script type="text/javascript"> function alertSelection()
So I have the following html: <div id=divForComponents> <input type=button value=+ onclick=addFilter('divForComponents')/> </div> And
I have the following HTML w/Javascript code (note: this only works in Internet Explorer):
I have the following markup (this is an example there are hundreds) <div class=Q3>
I have the following jsfiddle setup: http://jsfiddle.net/cvn6n/ Based on the radio selection a div
I have the following code, which I want to load values on a selection
I have the following HTML5 content: <section contenteditable=true id=editable class=ui-selectee ui-selected> <span>something</span> <span>something</span> <span>something</span>
I have the following example data in javascript: var variations = [ {group: 1,
I have the following code in my controller. This works fine in Internet Explorer 9 and

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.