HTMLService / Google Apps脚本中的日期选择器 [英] Date picker in HTMLService / Google Apps Script
问题描述
我想使用日期选择器来更轻松地在正在开发的应用中选择日期,但是我不知道如何使用Google Apps脚本中的HTML服务使其发挥作用。
如果你能为我提供一个这样的例子,我真的很感激它,因为我真的需要它
我想要类似这: http://jqueryui.com/datepicker/
< div class =demo>
< style type =text / css> .demo {margin:30px;颜色:#AAA; font-family:arial sans-serif; font-size:10pt}
p {color:red; font-size:14pt}
< / style>
< link rel =stylesheethref =// ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/cupertino/jquery-ui.css\">
< script src =// ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"> ;</script>
< script src =// ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js\"> ;</script>
< h1>欢迎使用一些随机页面< / h1>
< p>请在下面选择一个日期:< / p>
点击这里:< input type =textname =dateid =datepicker/>
< input type =textid =alternatesize =30>< / p>
< script>
$(#datepicker).datepicker({
altField:#alternate,
altFormat:DD,d MM,yy,
showWeek:true,
firstDay:1,
});
< / script>
< / div>
Code.gs:
function doGet(){
return HtmlService.createTemplateFromFile('index')。evaluate()。setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
请注意,建议在不同文件中将html和脚本的样式分开,请参阅Google HTML服务文档中的最佳实践文章,我没有在这里做这件事是为了让这个例子简单易读。
I would like to use a date picker to make easier the way to pick a date in an app that I am developing, however I dont know how to make it functional using HTML Service in Google Apps Script.
If you could provide me an example of this, I would really appreciate it since I really need it
I would like something like this: http://jqueryui.com/datepicker/
You just need to include the JQuery library in your code, a basic example is as follows :
<div class="demo" >
<style type="text/css"> .demo { margin: 30px ; color : #AAA ; font-family : arial sans-serif ;font-size : 10pt }
p { color : red ; font-size : 14pt }
</style>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/cupertino/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<h1>Welcome to some random page</h1>
<p>Please select a date below :</p>
click here : <input type="text" name="date" id="datepicker" />
<input type="text" id="alternate" size="30"></p>
<script>
$( "#datepicker" ).datepicker({
altField: "#alternate",
altFormat: "DD, d MM, yy",
showWeek: true,
firstDay: 1,
});
</script>
</div>
Code.gs :
function doGet() {
return HtmlService.createTemplateFromFile('index').evaluate().setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
Note the it is advised to separate style from html and script in different files, see the best practice article in Google HTML Service documentation, I didn't do it here to make the example short and easier to read.
这篇关于HTMLService / Google Apps脚本中的日期选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!