how to detect a DropDownList selectionchange and reteive the selected value on the client with javascript?

Last post 11-20-2008 2:31 PM by budugu. 3 replies.

Sort Posts:

  • how to detect a DropDownList selectionchange and reteive the selected value on the client with javascript?

    11-20-2008, 2:12 PM
    • Member
      113 point Member
    • bcweed966
    • Member since 11-27-2006, 2:40 AM
    • Posts 657

    I am starting with javascript and need to know how to detect the selection change of a dropdownlist in javascript?

    thank you

  • Re: how to detect a DropDownList selectionchange and reteive the selected value on the client with javascript?

    11-20-2008, 2:19 PM
    Answer
    • All-Star
      25,534 point All-Star
    • budugu
    • Member since 01-12-2006, 2:15 PM
    • North Carolina
    • Posts 3,802

    You can use "onchange" event in JS..check this.. 

    DropDownList1.Attributes.Add("onchange", "getIndex();") ;// where getIndex is JS function
     
    Vijay Kodali || My Blog


    "Don't be afraid to be wrong; otherwise you'll never be right."
  • Re: how to detect a DropDownList selectionchange and reteive the selected value on the client with javascript?

    11-20-2008, 2:26 PM
    • Member
      113 point Member
    • bcweed966
    • Member since 11-27-2006, 2:40 AM
    • Posts 657

    thank you.

    how do I retreive which value was selected? what is the javascript property that retreives the user selection? is it .value or .selectedvalue?

     

    thanks again

  • Re: how to detect a DropDownList selectionchange and reteive the selected value on the client with javascript?

    11-20-2008, 2:31 PM
    Answer
    • All-Star
      25,534 point All-Star
    • budugu
    • Member since 01-12-2006, 2:15 PM
    • North Carolina
    • Posts 3,802

    bcweed966:
    how do I retreive which value was selected?
     
    var e = document.getElementById("DropDownList1"); //If it doesn't work, use clintID
    var str = e.options[e.selectedIndex].value;  
     
    Vijay Kodali || My Blog


    "Don't be afraid to be wrong; otherwise you'll never be right."
Page 1 of 1 (4 items)