Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
I'm trying to store an element from the users input but I cant

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!