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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:54:39+00:00 2026-06-13T07:54:39+00:00

My generated drop-down menu works in Firefox and IE but not Google Chrome. I

  • 0

My generated drop-down menu works in Firefox and IE but not Google Chrome. I have

function characterList(){
    //code removed that generates select list 
    var optionContainer = document.createElement("option");
    optionContainer.innerHTML = "Show All Character Lines";
    addEvent(optionContainer, "click", filterChar, false);
    selectContainer.appendChild(optionContainer); //appends option to select menu

    for (var i = 0; i < menu_lines; i++){
       var optionContainer1 = document.createElement("option");
       optionContainer1.innerHTML = "blah" //simplified so that names in menu are all "blah"
       selectContainer.appendChild(optionContainer1);//appends option to select menu
       addEvent(optionContainer1, "click", filterChar, false);//I think the problem is here.
    }
}

function filterChar(){
    alert("filterChar");
}


function addEvent(object, evName, fnName, cap) {
   if (object.attachEvent)
       object.attachEvent("on" + evName, fnName);
   else if (object.addEventListener)
       object.addEventListener(evName, fnName, cap);
}

characterList populates a drop-down menu (of the select option type) with the names taken from h3 headings of an HTML file. This works fine. The problem is that in Google Chrome filterChar is not called on drop-down menu clicks. I have a function given to me (attachEvent) that’s supposed to be all-browser compatible. Please someone help.

  • 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-13T07:54:40+00:00Added an answer on June 13, 2026 at 7:54 am

    You need to attach a single event listener to your select element. Option elements aren’t regular DOM elements which is why listening to their onclick doesn’t work.

    Attaching a single onchange event listener to a select will fire when the selection has changed:

    addEvent(selectContainer, "change", filterChar, false);
    

    You can get reference to the select in the callback function using the event object passed as the first parameter:

    function filterChar(e){
        var select = e.target;
        alert("The selected item was index "+select.selectedIndex);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I generated a drop down menu with the code below. How can I set
I am using this function as a calender drop down menu. I am not
I am frustrated. I have one website where my drop-down CSS menu works and
I have a drop down menu generated like this: <select multiple=multiple name=application_occupation id=application_occupation value={$fields.Occupation}
I have a drop-down list which is generated based on the following sql query:
I have a drop down list which is dynamically generated using ajax on page
I have 2 drop down menus, the options in the second drop down menu
I have the following bit of code. I'm trying to dynamically add drop-down options
I have a drop-down/multi-level CSS menu on a page. The menu however doesn't appear
I want to generate the drop down menu, which the menu are generate from

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.