Hi I am wondering how do I add javascript if condition inside in nested foreach loop expamle:
function validation(){
@foreach (var region in Model.DefaultDeliver)
{
//js code
if(document.getElementByName('#@( region.Region.RegionName)') != null){
foreach (var country in region.Region.Countries)
{
//js code
if(document.getElementByName('#@(region.Region.RegionName)') != null){
}
}
}
}
}
Place the @ before
If there is compiling confusion between the razor and js you can escape the javascript with
@:(note colon) for one lineor wrap several with text node