SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast dakine's Avatar
    Join Date
    Dec 2006
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Get the value of a drop down menu

    I've been messing round with some php classes that allow me to use Ajax drop down menus and I've got far enough but I now need to know how to get the value of the select list.

    What I want to do is when there is a change on the menu I want to pass its value off to a JavaScript function and pass it off into this PHP class.

    I know its something like document.elementsomething.value but I am not a JavaScript person and I am not sure.

    Thanks in advanced,
    Mark

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The onchange event is the thing to use. Say the dropdown has the id 'dogbreeds':
    Code Javascript:
    var dropdown = document.getElementById('dogbreeds');
    dropdown.onchange = function() {
      doSomething(this.value);
    }
    where doSomething() is your Ajax magic.


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
  •