UPD: Decided
It's script.google.com question.
I have Spreadsheet with information (row - data \ column - time), every cell inside is number of free "spaces".
Example:
Date\Time | 11:00:00 | 15:00:00 | 17:00:00
01.09.2019| 10 | 15 | 30
02.09.2019| 10 | 15 | 30
03.09.2019| 10 | 15 | 30
04.09.2019| 10 | 15 | 30
After inputting in Web form date and time - program should show me how much "space" is free.
- Now have 3 steps after web form :
- Get row from form (data)
- Get column from form (time)
- Get cell value and return it in form (sheet.getRange(row, col).getValue();)
How to connect 3 functions together?
// Get information from form
<script>
function getEmptySpace(){
var presentDate = document.getElementById("dt").value;
var presentTime = document.getElementById("tm").value;
if(presentDate.length >= 10 && presentTime.length >= 8){
google.script.run.withSuccessHandler(updateEmptySpaceAdult).getSpaceAdult(presentDate,presentTime);
}
}
function updateEmptySpaceAdult(spaceAdult){
document.getElementById("anav").value = spaceAdult;
}
</script>
// My 3 functions, which sholud get cell value and return it in form
//Function 1 - getRowNum
function getRowNum(){
var sheet = SpreadsheetApp.openByUrl(url).getSheetByName("Ticket");
var data = sheet.getDataRange().getValues();
var name = "19.12.2018"; //Here should be arg "presentDate" (.getSpaceAdult(presentDate,presentTime);)
for(var i = 0; i<data.length;i++){
if(data[i][0] == name){ //[0] because serch in column A
return i+1;
}
}
}
//Function 2 - getColNum
function getColNum() {
var sheet = SpreadsheetApp.openByUrl(url).getSheetByName("Ticket");
var time = "17:00:00"; //Here should be arg "presentTime" (.getSpaceAdult(presentDate,presentTime);)
var range = sheet.getRange(2, 1, 1, sheet.getMaxColumns());
var values = range.getValues();
for (var row in values) {
for (var col in values[row]) {
if (values[row][col] == time) {
return parseInt(col) + 1;
}
}
}
}
//Function 3 - getCellValue
function getCellValue(){
var sheet = SpreadsheetApp.openByUrl(url).getSheetByName("Ticket");
var row = 8.0;
var col = 4.0;
var value = sheet.getRange(row, col).getValue();
}
// I think main Function is - .getSpaceAdult(presentDate,presentTime)
function getSpaceAdult(presentDate,presentTime){
*Call Function 1 - getRowNum() with arg "presentDate" and get RowNumber
*Call Function 2 - getColNum() with arg "presentTime" and get ColNumber
*Call Function 3 - getCellValue() by returns "getRowNum and getColNum" and show tabel cell value
In the end function getSpaceAdult = tabel cell value
}
getRowNum
function'sname
isundefined
– TheMaster