Hello Experts,
I am using mvc
In create view i have dropdownlist and i read the value of selected text from dropdown and set to the hidden field.
Now i want postback hidden field and read that value to the server
below create view code
@Html.DropDownList("dealerList", null, "---- Select Dealer ----", new { @class = "form-control", @onchange = "getSelectId();" })
<script>
function getSelectIdpro() {
var select = document.getElementById("productList");
var selectedID = select.options[select.selectedIndex].value;
var selectedText = select.options[select.selectedIndex].text;
alert("Id is " + selectedID);
alert("Name is " + selectedText);
$("#hiddenfield").val(selectedID);
};
</script>
please help
Thank You