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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:03:45+00:00 2026-06-07T03:03:45+00:00

I have a select element which will be displayed on mobile device <form> <select

  • 0

I have a select element which will be displayed on mobile device

<form>
<select id="selectMe" >
    <optgroup label="Australia">
        <option value="AustCars">Australia Cars Report</option>
        <option value="AustBikes">Australia Bikes Report</option>                
    </optgroup>
    <optgroup label="New Zealand">                    
        <option value="NZCars">New Zealand Cars Report</option>
        <option value="NZBikes">New Zealand Bikes Report</option>                
    </optgroup>
</select>
</form>​

Two things to note:

  • I want to display the full name Australia Cars Report when closed, to remove the ambiguity between Australia and New Zealand.
  • I want to use the shorter version Cars Report when the select is opened, because the full name Australia Cars Report is too long for the iPhone selector (not actual names, but renders as Austr...rs Report or similar) and the country is implicit in the optgroup.

My approach (based on Change a select list display value upon selecting description) is to modify the value of each item when the control gets focus, and then un-modify when it loses focus. And that’s about where I get stuck.

I have two problems here:

  • I can get the focus event, but there’s not ‘lostfocus’ event. I can’t use the ‘changed’ event because the user might not have actually changed the selection.
  • I don’t know how to get the value of the optgroup to add and remove from the option text. By this I mean that I need to find, for Australia Cars Report, that it is nested under Australia and thus I can remove that word from the display text.

I can use javascript or jQuery, or other tools if applicable. Open to suggestions of an easy way to do this that I’ve overlooked, too.

  • 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-07T03:03:46+00:00Added an answer on June 7, 2026 at 3:03 am

    I can get the focus event, but there’s not ‘lostfocus’ event. I can’t use the ‘changed’ event because the user might not have actually changed the selection.

    Use blur.

    I don’t know how to get the value of the optgroup to add and remove from the option text.

    A little unclear, but I’ll hazard a few guesses to get you started:

    • You’ll need to give the specific group an ID to access it uniquely, e.g.

      var fooElement = document.getElementById("foo")

    • You can get the selected object using fooElement.selected
    • You can get all of the options using fooElement.options[]. Adding and removing new DOM elements to this list will add or remove them in the HTML DOM.
    • Values of an option can be found using .value or .text.

    Try looking up the select tag in HTML, and the javascript to interact with that type of element. Good luck.

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

Sidebar

Related Questions

I have a select element. <select class='cSelectType'> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> <option
I have a select form element with 5 options. If option 2 is selected
I have a SELECT element in which I need to auto-select the appropriate option
I am creating a web page which will have a Select element with a
i am fetching all the values from select element, which will not have selected
I have a select element containing different titles; as an example: <select name=titles> <option
I have a form in which a user can select multiple options in a
Making a simple program which will generate a multiple choice form. I have an
I have a select element which I'm creating through javascript (DOM) var cell_stock_id =
I'm looking to make a selector which will select all elements if they have

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.