Using value from HTML page in java script function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishekbrave
    New Member
    • Dec 2007
    • 79

    Using value from HTML page in java script function

    Hi I have a combo box having the values of year.
    [HTML]<select name=year value=2008>
    <option value=2007>2007 </option>
    <option value=2007>2006 </option>
    <option value=2007>2005 </option>
    </select>&
    [/HTML]I want to use this value of year in my java script function
    [CODE=javascript]function veiw()
    {

    //java script code
    }
    </script>
    [/CODE]How can i use this value in the function...
    i tried using document.year.v alue but its not working...
    Last edited by acoder; Feb 25 '08, 08:20 AM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Please enclose your posted code in [code] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [code] tags in future. Thanks!

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      [code=javascript]document.forms[NameOfForm].elements["year"].value[/code]where NameOfForm is the name of the form.

      Comment

      Working...