I have a JS function which I want to loop round a c# object passed from the controller. I then want to compare it to a HTML input value - which I have passed into the JS function as a string. Function is called like
searchReleases($("[name=release]").val());
function searchReleases(givenName) {
var list;
var data = givenName;
@foreach (var a in @Model.Releases) {
if (@a.Name.Contains(givenName)) {
list+= a.Name + "=";
}
}
}
However I can't access the JS variable givenName within the IF statement. I have spent a while trying to find an answer on google but have yet found a workable solution.