Monday, 14 October 2013

Dropdown Selected Value and Text


@Html.DropDownListFor(model => model.Country, new SelectList(((System.Collections.IEnumerable)ViewData["CList"]), "cid", "cname"), "--Select--", new { @Class = "txtbox", onchange = "CountryChange()", id = "ddlcountry" })

function CountryChange() {
        var dropdownSelect= document.getElementById("ddlcountry");
        var selectedValue = dropdownSelect.options[dropdownSelect.selectedIndex].value;
        var selectedText = dropdownSelect.options[dropdownSelect.selectedIndex].text;    
    }

No comments:

Post a Comment