Automatic selection of <OPTION> after info sent to form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hydrogen
    New Member
    • Mar 2008
    • 3

    Automatic selection of <OPTION> after info sent to form

    Hello there,

    I've got a few dropdown 'SELECT' controls on a page that represent the days months and years. A little popup calendar will send back the day month and year and insert them into a text box with no problems.

    But I want the drop down menus to have their selected values changed using javascript.

    Is this possible anyone?

    Thanks

    Adrian.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Yes, set the value of each select drop-down as required.

    Make sure that each option has a value otherwise this won't work in IE.

    Comment

    • Hydrogen
      New Member
      • Mar 2008
      • 3

      #3
      Originally posted by acoder
      Yes, set the value of each select drop-down as required.

      Make sure that each option has a value otherwise this won't work in IE.
      Think you've missed the point. I want the 'SELECT' drop down to highlight the matching value to the value that is sent from the calendar javascript.

      So if Month is sent in as "March" then the option :

      <option value='March'>M arch</option>

      will be selected.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Let's say you have a select with ID "month", then the following should work:
        [code=javascript]document.getEle mentById("month ").value = calMonth;
        // where calMonth is the month sent from the calendar[/code]

        Comment

        • Hydrogen
          New Member
          • Mar 2008
          • 3

          #5
          Thanks all,

          the :
          Code:
          document.getElementById("month").value = calMonth;
          doesn't work with the drop down menu's it appears.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Can you post some code or a test link.

            Comment

            Working...