How do I retrieve Drop Down Menu opions? Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divina11
    New Member
    • Aug 2007
    • 55

    How do I retrieve Drop Down Menu opions? Javascript

    I'm trying to retrieve the options below, depending on the one the user selects, I'm bulliding a Calculator Program where user inputs 2 values via input box and then selects an operation:

    Code: (Javascript)

    [HTML]<select id="mySelect">
    <option>+</option>
    <option>-</option>
    <option>*</option>
    <option>/</option>
    </select>[/HTML]

    I've tried the following statement and then tried to pass 'operation' to another function, however the value I retrieve is [object]: var operation=docum ent.getElementB yId("mySelect") ;

    So, How do I retrieve Drop Down Menu opions? and then pass them to another function?

    Ta

    P.S. Is it necessary I place <FORM> tags around the <select> tags?
    Last edited by gits; Aug 21 '07, 12:41 PM. Reason: added CODE tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    heya divina11 ...

    this is my last friendly warning about using code tags when posting code ... please use them whenever you post source-code ...

    regards

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Give values to the options and pass the .value to the function. At the moment, you're passing the object rather than the value.

      And yes, you should put form tags around the select and all form elements.

      Comment

      • divina11
        New Member
        • Aug 2007
        • 55

        #4
        Thank you Acoder, the .value worked.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Glad you got it working. Post again if you have any more questions.

          Comment

          Working...