James
James

Reputation: 1945

msdropdown get selected value

I am using msdropdown plugin from here

I build dropdown like this

var jsonData = [
            {
                text: "Facebook",
                value: 1,
               description: "Description with Facebook",
                image: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
            },
            {
                text: "Twitter",
                value: 2,

                description: "Description with Twitter",
                image: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
            }
            ];
var jsn = $("#byjson").msDropDown({byJson:{data:jsonData, name:'payments'}}).data("dd");

I want to get selected value and i tried code like this

$("#byjson").change(function () {
        var selectedIndex = $(this).val();
        alert("value =" + selectedIndex);
    });

When i select something from dropdown i get value as blank always. I am not able to get selected value. What am i doing wrong?

Upvotes: 0

Views: 1233

Answers (1)

James
James

Reputation: 1945

Ok i found it .. Its like this

   $("#byjson").change(function () {
        var selectedIndex = $('#byjson option:selected').val();
        alert("value =" + selectedIndex);
    });

Upvotes: 1

Related Questions