I have an Html.DropDownListFor, a textbox, and a model that contains a list "sourceWatchListParameters".
My end goal is, when an item is selected in the dropdownlist, populate the textbox with a property "DefaultParameter" for that particular sourceWatchList.
$(function() {
$('select#WatchListDropDown').change(function () {
var e = document.getElementById("#WatchListDropDown").selectedIndex.value;
@foreach (var watchlist in Model.sourceWatchListParameters)
{
@:if (watchlist.WatchListId == e)
{
@: var def = document.getElementById("expDefault");
@: def.value = watchlist.DefaultParameter;
}
}
})
});
The function is called correctly, but I can't figure out the logic/syntax to locate the right sourceWatchListParameter and display its DefaultParameter. As it is now, I see no change in the textbox on selection. I'm sure there's a simpler way to rewrite this.
Thanks for any guidance
watchlistand why you're mixing JS and jQuery?