Results 1 to 3 of 3

Thread: handle combo box with JavaScript

  1. #1
    Join Date
    Apr 2008
    Posts
    58
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Default handle combo box with JavaScript

    Hi ,

    i got a very simple problem (at least i gues it is)...

    I have a html combobox in a form, and i would like to handle the selected option with a javascript function.
    My problem seems to be : how can i get the selected option with javascript ...
    not sure ...

    Here is my error message (got with firebug) :
    document.frmname have no properties

    My code :
    Code:
    <script type="text/javascript">
    <!--
         function getit(comboboxname){
              SelectedDownload=document.frmname.getElementById(comboboxname).value;
              alert(SelectedDownload); /* debug */
         }
    -->
    </script>
    <form name="MyDownloads">
         <select name="MyDownloadItems" id="MyDownloadItems" size="1" style="background-color:#5aff52;">
              <option value="download1.zip">Download 1</option>
              <option value="download2.zip">Download 2</option>
              <option value="download3.zip">Download 3</option>
         </select>
         <input type="button" name="Download" value="Download" onclick="getit('MyDownloadItems');">
    </form>

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    See if removing the highlighted helps:
    Code:
     SelectedDownload=document.frmname.getElementById(comboboxname).value;
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    sfchun (06-17-2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    58
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Default

    works great , thanks !
    I was thinking too much complicate...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •