Prakash

Prakash

  • NA
  • 258
  • 77.6k

Read dropdown value at server side from hidden field

Aug 30 2016 6:24 AM
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
 

Answers (2)