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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:07:45+00:00 2026-06-10T12:07:45+00:00

I currently have a select which shows options as <option>{{ tag.name }} ({{ tag.count

  • 0

I currently have a select which shows options as

<option>{{ tag.name }} ({{ tag.count }})</option>

However, I would like that when the user selects the option, in the selected options, only the name is visible and not the last part. Think of how stack* shows the tag count but hides it when you select it.

Ideas? Thanks.

Edit: Sorry for not being clear. In chosen, when you select an option, a textbox fills up with the selected data. I want that text to be modified, not the one on the <select>!

  • 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-10T12:07:45+00:00Added an answer on June 10, 2026 at 12:07 pm

    EDIT: For your edit, if the option elements have a value attribute set to the text you want to use try:

    $(document).ready(function() {
        $("select").change(function() {
            $("input").val( $(this).val() );
        }).change();
    });​
    

    Demo: http://jsfiddle.net/CdKGT/2/

    Or if you can’t use the value attribute for some reason and want to extract the text from what is displayed:

    $("select").change(function() {
        $("input").val( $("option:selected",this).text().replace(/ \(\d+\)$/,"") );
    }).change();
    

    Demo: http://jsfiddle.net/CdKGT/3/

    Obviously you’d use an id or class to identify the select and input rather than just $("select") and $("input"), but you get the idea.

    MY ORIGINAL ANSWER (for my interpretation of your original question):

    You could do something like this:

    ​<select>
    <option value="css" data-count="1">css 1</option>
    <option value="html" data-count="55">html 55</option>
    <option value="java" data-count="37">java 37</option>
    <option value="javascript" data-count="20">javascript 20</option>
    <option value="jquery" data-count="12">jquery 12</option>
    </select>
    

    And then:

    ​$(document).ready(function() {
        $("select").change(function() {
            $(this).find("option").html(function(){ return this.value + " " +
                                                           $(this).attr("data-count"); });
            $("option:selected",this).html(this.value);
        }).change();
    });​​​
    

    Demo: http://jsfiddle.net/CdKGT/1/

    (Obviously you can optimise the function a bit by caching the jQuery objects and so forth, but I kept it simple for proof of concept.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a select-case that will read a name field from a recordset,
I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
I have an select options which can be of any numbers by name: prod_search[]
I have a webpage in which I have a div that I would like
I currently have a form in which I can select a list of options
I currently have a ajax script that dynamically builds two select boxes enabled with
I have a asp radio button list which has 3 options: Option 1 Option
I have a standard select box which I'm populating using jquery by appending options,
Which is the best way to add <option>...</option> to a select that has been
I have the following script currently, which gets the category IDs as arrays: $sql_select_categories

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.