I am trying to implement a code to get checkbox list attr('name') while return 'undefind' word. What is the reason for this and How this one remove?
jQuery(document).on("change", "#chkdaypart", function () {
var daypartText;
$(this).each(function (e) {
if (this.checked) {
daypartText = daypartText + $(this).attr('name');
if (daypartText == "undefinedDaytime–Weekday(06:26:00-17:25:00)") {
$('#daysTD').html('')
$('#daysTD').html('
}
else if (daypartText == "undefinedDaytime-Weekend(06:26:00-17:25:00)") {
$('#daysTD').html('');
$('#daysTD').html('
}
}
else {
$('#daysTD').html('');
$('#daysTD').html('
}
});
});
var daypartText;
$(this).each(function (e) {
if (this.checked) {
daypartText = daypartText + $(this).attr('name');
if (daypartText == "undefinedDaytime–Weekday(06:26:00-17:25:00)") {
$('#daysTD').html('')
$('#daysTD').html('
- All
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
}
else if (daypartText == "undefinedDaytime-Weekend(06:26:00-17:25:00)") {
$('#daysTD').html('');
$('#daysTD').html('
- All
- Sunday
- Saturday
}
}
else {
$('#daysTD').html('');
$('#daysTD').html('
- All
- Sunday
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
}
});
});
And 'chkdaypart' id contain list of checkboxlist which return list of names like this:-
All
@items.Text
@foreach (var items in ViewData["daypart"] as List
{
}


Manas MohapatraPosted Jan 18, 2016, 2:37 AM
Abhilash J APosted Jan 18, 2016, 2:24 AM
All
@foreach (var items in ViewData["daypart"] as List
{
@items.Text
}
always daypartText contain 'undefined'. how to avoid this one from daypartText.
Actually I want,
daypartText="Daytime–Weekday(06:26:00-17:25:00)";
not like this,
daypartText = "undefinedDaytime–Weekday(06:26:00-17:25:00)";