I'm trying to store an element from the users input which is called wn but its not being stored and when I logger.log(wn) im just keep getting the array (all the numbers, from 348-372)
I used wn.getEllemntById(input); but its not working (I'm sure it has something to do with the scope or something but i just don't know how to fix it).
I also don't know how to stop the program and make it continue when the user selects a weak and click confirm.
*I'm using java Script in google app script
*I'm getting the users input from an excel sheet
function menu(){
//get the good week number
var date = new Date();
var wn = [(Math.floor(WEEKNUMBER(date)) 3).toFixed(0)]
do {
wn.push((wn[wn.length-1]-1).toFixed(0))
} while(wn[wn.length-1] != 348);
var line = "<select style='width:60px;height:40px;' id='input'>"
for ( var x in wn ) // thats the loop taht is going to show all the weeks for the user
line ="<option>" wn[x] "</option>"
line ="</select>"
Logger.log(wn);
var ui = SpreadsheetApp.getUi();
var html = HtmlService.createHtmlOutputFromFile('Selector')
.setWidth(200)
.setHeight(150).setContent("<div>" line "</div><br>. <div><button onclick='reset()'>Confirm</button> </div>. <script>function reset(){var wn = document.getElementById('input').value;document.getElementsByTagName('Body')[0].style.cursor = 'wait';google.script.run.withSuccessHandler(function (){google.script.host.close();}).readWP2(wn); Logger.log(wn);}</script>")
SpreadsheetApp.getUi() // Or DocumentApp or SlidesApp or FormApp.
.showModalDialog(html, 'Please select a week number');
Logger.log(wn);
}
Summary: I want to stop the program and make it continue when the user selects a weak and click confirm. How to store the week number the user selects in a variable.
Please let me know if you need any more explanation
Thank you
CodePudding user response:
I believe that you just need this function:
gs:
function readWP2(wn) {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1');
sh.getRange("A1").setValue(wn);
}
