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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:25:45+00:00 2026-06-03T06:25:45+00:00

I have a select, for which a onchange event is set. The problem is,

  • 0

I have a select, for which a onchange event is set.
The problem is, in Firefox only (FF v. 12), that the onchange event is triggered even if the user does not click on any option;
just hovering the option it is enough to trigger it.

i.e.: If the user clicks on the select, hovers one of the options and then he clicks outside the select, the value of the select changes (even if the shown value does not) thus the event is triggered.

This does not happen if one of elements of the select is already selected.
The behavior is more or less the same as in this Mozilla bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=265047

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

    This is certainly a bug in Firefox that assign the selected value and selected index upon hovering the items, when there is no selected index defined.

    While I can’t fix the bug, one workaround that is pretty simple and working is adding empty and hidden item to the list to be the first item and assigning it as the selected item.

    For example:

    <select id="mySelect">
        <option value="" style="display: none;"></option>
        <option value="1">first</option>
        <option value="2">second</option>
    </select>
    

    The user won’t see any change and when you “clear” the selection, assign selected index of 0 instead of -1 e.g.

    var oDDL = document.getElementById("mySelect");
    oDDL.selectedIndex = 0;
    

    Live test case – behaves properly even on Firefox now.

    Update – The above code is not working properly in IE8 as it still showing the first empty option. To solve this, it’s possible to simply remove the option in all browsers that support it when the browser is not Firefox. Updated code will be:

    navigator.sayswho = (function(){
        var N = navigator.appName, ua= navigator.userAgent, tem;
        var M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
        if (M && (tem = ua.match(/version\/([\.\d]+)/i)) != null) M[2] = tem[1];
        M = M? [M[1], M[2]]: [N, navigator.appVersion, '-?'];
        return M;
    })();
    
    window.onload = function() {
        var oDDL = document.getElementById("mySelect");
        oDDL.selectedIndex = 0;
        var blnFirefox = (navigator.sayswho[0].toLowerCase().indexOf("firefox") >= 0);
        if (!blnFirefox && oDDL.remove) {
            oDDL.remove(0);
            oDDL.selectedIndex = -1;
        }
        oDDL.onchange = function() {
            alert("hello");
        };
    };
    

    The function that identifies the browser was taken from this answer.

    Updated fiddle – working in Firefox, Chrome, IE9 and IE8.

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

Sidebar

Related Questions

I have the following LINQ Select which does not work. Data.Select(d => d.Value.IsDirty =
I have a dropdownlist which is declared as follows: <select onchange=reloadValues(this,event);> ... options here
Hello I have a html select which has an onchange event. And whenever a
I have a method which detects the onChange event on a select box. When
I have an xsl page which uses <xsl:variable name=pos select=Position()/> in the onchange events
I have a div which hides a select box. When a user clicks on
I have a select box that should be populated only when clicked. The query
I have the following code which is designed to create an onchange event handler
I want to add a simple onChange event to a select list I have
I have an input field with onChange event which triggers an AJAX call which

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.