我想显示注册用户在注册时填写的开放时间:
这是'value
'&它以这种方式存储在DB中:
[
{"day":"Maandag","daylabel":"Maandag","fromtime":"15:30","fromtimelabel":"3:30 pm","totime":"22:00","totimelabel":"10:00 pm"},
{"day":"Dinsdag","daylabel":"Dinsdag","fromtime":"15:30","fromtimelabel":"3:30 pm","totime":"22:00","totimelabel":"10:00 pm"},
{"day":"Donderdag","daylabel":"Donderdag","fromtime":"15:30","fromtimelabel":"3:30 pm","totime":"22:00","totimelabel":"10:00 pm"},
{"day":"Vrijdag","daylabel":"Vrijdag","fromtime":"15:30","fromtimelabel":"3:30 pm","totime":"22:00","totimelabel":"10:00 pm"},
{"day":"Zaterdag","daylabel":"Zaterdag","fromtime":"09:30","fromtimelabel":"9:30 am","totime":"+00:00","totimelabel":"12:00 am (next day)"},
{"day":"Zondag","daylabel":"Zondag","fromtime":"09:30","fromtimelabel":"9:30 am","totime":"+00:00","totimelabel":"12:00 am (next day)"}
]
这是我解析value
:
config.profile.core.parseAvailability = function(value){
if(value){
try {
var availabilityDays = JSON.parse(value);
$jq.each(availabilityDays, function(index, day) {
$jq('#availability').append('<div class="col-sm-5">'+day['daylabel']+'</div><div class="col-sm-7">'+day['fromtime']+' - '+day['totime']+'</div>');
});
} catch (error) {
console.error(error);
}
}
};
这就是它在页面上显示的方式:
问题:
正如你可能看到的那样,星期三的日子(荷兰'woensdag'介于'dinsdag'和'donderdag'之间)缺失,因为它没有故意填写(可能是在特定的一天关闭)。因为那天没有存储,我无法显示它。
何时我会显示空值的缺失日?
答案 0 :(得分:2)
不是循环遍历 的数据,而是遍历您想要的数据,然后显示与之匹配的数据
{{1}}