In View, the user will check 1 or more names from what's displayed ...
<form name=chkAttend method=post onsubmit='return validate(this)'>
<div>
@if (Model.evModel.Participants != null)
{
foreach (var fi in Model.evModel.Participants)
{
<div>
@if (@fi.AttendedFlag != true)
{
<input type="checkbox" id="c_@fi.EnrollmentId" name="MyCheckboxes" value="@fi.EnrollmentId" />
<label for="c_@fi.EnrollmentId" aria-multiselectable="True"></label>
<span></span> @fi.EnrollmentId @fi.ParticipantName
}
</div>
}
}
<input type=submit value="Confirm Attendance">
</div>
</form>
After selecting names, call the function to identify which names checked. The checked names only need to be passed to the controller. The problem - I'm getting the error message: Error 49 The name 'id' does not exist in the current context
function validate(form) {
var id = ""
for (var i = 0; i < document.chkAttend.MyCheckboxes.length; i++)
{
if (document.chkAttend.MyCheckboxes[i].checked)
id += document.chkAttend.MyCheckboxes[i].value + ","
}
if (id == "")
{
alert("Place a check mark next to event's Participant")
}
else
{
@Html.Action("ConfirmAttendance", "Admin", new { eventid = @Model.evModel.Id, enrollid =id })
}
return false;
}
How do I pass ONLY the checked items as parameter for the function in my controller?