Extracting values from ` exists all right; it's ID is `selectBox` and I'm using the variable `var selectbox = document.getElementById("selectBox")` – Singular1ty Sep 09 '11 at 03:58

  • Just a comment: the script on this answer run well on jsFiddle, but only after removing "=" from "alert=(x[i]);". – Hoàng Long Sep 09 '11 at 04:04
  • 1

    The problem is that calculate is the ID of the element too. And oddly enough it believes that calculate is that DOM object not you function: proof. I changed the function name to calculates.

    I only found out last week that you can reference your elements with IDs with said IDs.

    <div id="really">Yep for some reason</div>
    

    ... later in javascript

    // no document.getElementById, just
    // let me be very clear, THIS IS WRONG TO USE VERY BAD SO EVERYONE CAN KNOW NOT TO USE THIS
    // but it does work this way so be aware
    really.innerHTML = "I guess he was right.";
    
    Joe
    • 80,724
    • 18
    • 127
    • 145
    • OMG. That worked! Thanks so much! :D I'll keep that in mind...thanks so much, that worked in an instant! – Singular1ty Sep 09 '11 at 04:41
    • Nooo!!! **Don't use IDs as global variables!!** That is a really bad (non-standard) feature introduced by IE and copied by others to be compatible. **Please don't use it or recommend its use**. – RobG Sep 09 '11 at 05:31
    • 1
      @RobG, no where did I ever say that. Not once. – Joe Sep 09 '11 at 05:32
    • Right were you wrote `"// no document.getElementById, just really.innerHTML = "I guess he was right.";`. – RobG Sep 13 '11 at 01:14
    • @RobG, because that's how it works by default. That needs to be understood. – Joe Sep 13 '11 at 01:49
    • That **isn't** how it works by default at all, try it in Firefox with an HTML 4 strict DOCTYPE. If it needs to be understood, then you should explain it (you didn't). If you do then I'll remove the down vote. – RobG Sep 13 '11 at 02:54