1
我有一個HTML服務應用程序要求約會的日期參加一個類。當你選擇一個日期時,它會給你一個複選框,課程標題和課程描述。你想要檢查你想要參加的課程,然後點擊參加按鈕來記錄數據。我接到日誌的調用,因爲它記錄了一些內容,但它總是'null',而不是事件選擇。對象日誌爲空而不是日曆數據
這裏是我的code.gs:
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('index.html').setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
function listEvents(dateSelected) {
var calendar = CalendarApp.getCalendarById('CalendarID').getEventsForDay(new Date(dateSelected));
if (calendar[0] == null) {
var text = 'No classes for this date';
return text;
}
else {
var text = '<form id="eventsForm">';
for (var i=0; i < calendar.length; i++) {
text += "<input type='checkbox' name=";
text += i+1;
text += " value=";
text += calendar[i].getTitle();
text += ">";
text += calendar[i].getTitle();
text += ' - ';
text += calendar[i].getDescription();
text += '<br>';
}
text += "<input type='button' value='Attend' onclick='google.script.run.withSuccessHandler(test).processForm(this.parentnode)' />";
text += "</form>";
return text;
}
}
function processForm(x) {
Logger.log(x);
}
下面是HTML:
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/themes/redmond/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>
<div class="container" >
<div>
<h1>Welcome to the sign up page</h1>
<p>Please select a date for the class you'd like to attend below.</p>
<p>Click Here: <input type="text" name="date" id="datepicker" /><p>
</div>
</div>
<div id='test'></div>
<script>
$("#datepicker").datepicker();
$("#datepicker").on("change", function() {
var dateSelected = $(this).val()
google.script.run.withSuccessHandler(onSuccess).listEvents(dateSelected);
});
function onSuccess(eventText) {
document.getElementById('test').innerHTML=eventText;
}
</script>
當你點擊按鈕出席它去processFrom在code.gs和日誌但正如我所說它只記錄日期/時間和'空'而不是類。我只是想檢查我是否收回了一些東西,以便我可以將人們檢查的課程發送到電子表格以顯示誰來了。任何想法如何讓表單發回正確的數據?
哈羅德,我知道我們不會回覆這個(按照stackoverflow規則),但是:謝謝。神聖莫利我一直在尋找這兩天。再次感謝。 – user2093601