Displayed in my view is a list where each item contains a DropDownList specifying the status of each record. I am now attempting to retrieve the selected value in the DropDownList.
This is how I set up the DropDownList:
<div>
@Html.DropDownList("DeclineReasons", ViewBag.DeclineReasons as SelectList, new { @id=item.ProfessorSubmittedRequestFlowId+"Dec"})
</div>
When clicking on a button, I attempted to locate the DropDownList within the record using this code:
var SelectedDeclineReason = ProfessorSubmittedRequestFlowId + "Dec"
var e = document.getElementById("SelectedDeclineReason");
var SDeclineReasons = e.options[e.selectedIndex].value;
I also tried another method, but unfortunately, it did not work either:
var SelectedDeclineReason = ProfessorSubmittedRequestFlowId + "Dec"
var j=$('*[data-id=SelectedDeclineReason]');
Although SelectedDeclineReason displays the ID correctly, the element remains undefined in both cases.