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

  • Home
  • SEARCH
  • 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 6610185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:48:28+00:00 2026-05-25T19:48:28+00:00

For some reason this code doesn’t work in IE9 (could not try other versions

  • 0

For some reason this code doesn’t work in IE9 (could not try other versions of IE). When tried it worked fine in Chrome and Firefox.. Text boxes comes up with message "undefined" when a drop down item is selected.

I am not able to figure out whats wrong, I wanted this working primarily in IE9… Any help is greatly appreciated..

Code: http://jsfiddle.net/pimvdb/RemPF/1/

  • 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-05-25T19:48:29+00:00Added an answer on May 25, 2026 at 7:48 pm
    1. You don’t stop the function printColorAndGroup with a }.
    2. You should use an object for key/value pairs, not an array.
    3. You might want to use the literal notation for an object.
    4. Inside the onchange function, you can pass the select with this. So select.options[...] would then be possible and cleaner.
    5. Instead of names, you can also use IDs, so you don’t have to worry about [0] each time.

    Altered version: http://jsfiddle.net/pimvdb/RemPF/1/


    This is a literal object notation:

    var colors = { apple:   "red",
                   grape:   "purple",
                   milk:    "white",
                   cheese:  "yellow",
                   chicken: "white",
                   beef:    "red"    };
    

    This is how IDs work:

    <input type="text" id="food_group" ...>
    

    And you can fetch the element with:

    document.getElementById('food_group')
    

    This is how passing the select works:

    <select name="food" onchange="printColorAndGroup(this)">
    

    with the following JavaScript:

    function printColorAndGroup(select){
    var text = select.options[select.selectedIndex].value;
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason I never see this done. Is there a reason why not?
For some reason I'm not getting this. (Example model below) If I write: var
I have this code, and for some reason my $.post function fires twice in
For some reason my PDF upload form is failing consistently, I have this code:
I'm trying to build a binary tree, but from some reason my code doesn't
For some reason I can't get this to work at all. I have read
html Tidy gives this as output for some reason: <?xml version=1.0 encoding=utf-16?> <?xml version=1.0
For some reason, addAsync chaining in a flexunit test as described in this article
I know this is a dumb question. For some reason my mind is blank
Okay so im working on this php image upload system but for some reason

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.