如何在 HTML 和 Javascript 中创建动态每周计划?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6035215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 19:58:30  来源:igfitidea点击:

How can I create a dynamic weekly schedule in HTML and Javascript?

javascripthtmlcalendartabular

提问by whoabackoff

It's simple to create a table based layout for a weekly calendar with 7 columns for each day of the week and various rows for each hour of the week. I have no problem creating that. The hard part is filling in this table with daily 'events' dynamically (I'm not even sure how I would do this statically).

为每周日历创建基于表格的布局很简单,每周的每一天有 7 列,每周的每个小时都有不同的行。我没有问题。困难的部分是动态地用每日“事件”填充这个表(我什至不确定我将如何静态地做到这一点)。

The user will have access to a list of 'events' that they would like to add to their weekly schedule. And they need to be added dynamically to the webpage. Each event has a specific start and end time, and may occur on more than one day of the week. I'm not sure how I could possibly add these 'events' to my table layout without getting into a bunch of rowspan problems ( a lot of the events are various lengths and span different hours ). It would be easy if each event was always 1 hour long, but that's not the case.

用户将有权访问他们想要添加到每周日程表中的“事件”列表。并且它们需要动态添加到网页中。每个事件都有特定的开始和结束时间,并且可能发生在一周中的不止一天。我不确定如何将这些“事件”添加到我的表格布局中而不会遇到一堆 rowspan 问题(很多事件的长度和时间不同)。如果每个事件总是 1 小时,那会很容易,但事实并非如此。

I was thinking of making each day a respective table with a hidden hour column. I still feel like this will result in a huge mess. Any ideas?

我正在考虑让每一天都成为一个带有隐藏小时列的相应表格。我仍然觉得这会导致一团糟。有任何想法吗?

回答by Brandon Boone

Why reinvent the wheel?

为什么要重新发明轮子?

I think this covers all your concerns.

我认为这涵盖了您的所有担忧。

http://arshaw.com/fullcalendar/

http://arshaw.com/fullcalendar/