onchange event handler and select tags

Discussion in 'Javascript' started by yawnmoth, Dec 11, 2007.

  1. yawnmoth

    yawnmoth Guest


    When I select an item from the drop down menu, with the mouse, that
    selection appears in the div section below.

    When, however, I double click the drop down menu and then browse
    through the entries with the up / down arrow on the keyboard, the
    selection does not appear in the div. In IE7 it does but not in
    Firefox 2. Any ideas as to why and what I can do fix it?
    yawnmoth, Dec 11, 2007
    1. Advertisements

  2. yawnmoth

    yawnmoth Guest

    Also, any ideas as to why that page doesn't validate at

    yawnmoth, Dec 11, 2007
    1. Advertisements

  3. yawnmoth

    David Mark Guest

    It is not a drop-down menu. It is a select element.
    You mean when you focus the select. Double-clicking does nothing
    special. Clicking it twice in succession opens and closes the option
    Change this:

    onchange="document.getElementById('div').innerHTML =

    To this:

    onchange="document.getElementById('div').innerHTML = this.value"
    David Mark, Dec 11, 2007
  4. yawnmoth

    yawnmoth Guest

    I never implied double-clicking did anything special. You do,
    however, need to double-click to close the select whilst still leaving
    it focused to see the changes the select makes (since the div that's
    being changed would be covered up by an open select).

    Doesn't seem to make it behave any differently:

    yawnmoth, Dec 11, 2007
  5. yawnmoth

    David Mark Guest

    The onchange event doesn't fire in FireFox (or Windows Safari) until
    the element loses focus. This is correct per the w3c. It seems like
    it shouldn't fire when clicking an option in the list either.

    So the question arises, what are you trying to accomplish with this?
    If you want cross-browser consistency, you will need a different
    David Mark, Dec 11, 2007
  6. The ability to read can be of great advantage:

    | Line 12, Column 120: document type does not allow element "select" here;
    | [...]

    You should also enable Show Source and Verbose Output when validating there.

    Thomas 'PointedEars' Lahn, Dec 12, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.