使用JavaScript查看Google日历的日期和时间

发布于 2025-02-10 18:23:46 字数 2072 浏览 2 评论 0原文

我正在尝试让用户选择某些日期和时间,并检查日历,如果我们有任何事件干扰用户输入

<!DOCTYPE html>
<html>

<head>
<base target="_top">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">

<style>
</style>

</head>

<body>

<div>From<input class="w3-input w3-border" type="datetime-local" id="from"></div>
<div>To<input class="w3-input w3-border" type="datetime-local" id="to"></div>
<button style="width:100%" class="w3-button w3-black w3-section" onclick="check()">check</button>
<div style="display:none" id="no">Not Available</div>
<div style="display:none" id="yes">Available</div>

<script>
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault());// 2018-06-19T22:38:28+0000
</script>

<script>
function check() {
var startTime = document.getElementById("from").innerHTML;
var endTime = document.getElementById("to").innerHTML;
var cal = CalendarApp.getCalendarById("[email protected]");
var allEvents = cal.getEvents(new Date(startTime), new Date(endTime));
if (allEvents.length > 0) {
document.getElementById("no").style.display = "block";
}else {
document.getElementById("yes").style.display = "block";
}
}
</script>

</body>
</html>

我尝试了上述代码,但没有返回,感谢您的帮助

I'm trying to let the user chooses certain date and time and check the calendar if we have any events interfering with the user inputs

<!DOCTYPE html>
<html>

<head>
<base target="_top">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">

<style>
</style>

</head>

<body>

<div>From<input class="w3-input w3-border" type="datetime-local" id="from"></div>
<div>To<input class="w3-input w3-border" type="datetime-local" id="to"></div>
<button style="width:100%" class="w3-button w3-black w3-section" onclick="check()">check</button>
<div style="display:none" id="no">Not Available</div>
<div style="display:none" id="yes">Available</div>

<script>
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault());// 2018-06-19T22:38:28+0000
</script>

<script>
function check() {
var startTime = document.getElementById("from").innerHTML;
var endTime = document.getElementById("to").innerHTML;
var cal = CalendarApp.getCalendarById("[email protected]");
var allEvents = cal.getEvents(new Date(startTime), new Date(endTime));
if (allEvents.length > 0) {
document.getElementById("no").style.display = "block";
}else {
document.getElementById("yes").style.display = "block";
}
}
</script>

</body>
</html>

I tried the above code but it returns nothing, thanks for helping

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等往事风中吹 2025-02-17 18:23:46

InnerHTML仅用于元素括号内的内容。

对于输入,您需要这样的价值范围:

var inputValue = document.getElementById("myTextInputID").value;

innerHTML is only for content WITHIN the brackets of the element.

For inputs you would need the value-property like this:

var inputValue = document.getElementById("myTextInputID").value;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文