2

I've created a google scripts app that gives the user a prompt and accepts a single input, which is then used later on within the script (I'm querying an API using and outputting the results into Google sheets and need username / pwd etc).

My code so far:

var ui = SpreadsheetApp.getUi();
var result = ui.prompt('Please enter API password',
                       ui.ButtonSet.OK_CANCEL);
var button = result.getSelectedButton();
var text = result.getResponseText();
if (button == ui.Button.OK) {
    // User clicked "OK".
    var pw = text; 
 }

However, I would like to increase this to four string responses that are all captured as variables that are then used in the rest of the script. Is this possible without having multiple prompts?

Thanks for your help!

Anant

Anant
  • 715
  • 2
  • 9
  • 13
  • This answer may be helpful: https://stackoverflow.com/a/32610621 – Kos Jun 08 '18 at 14:05
  • 1
    You can use HTML `` tags. There are a few ways to set up the HTML. You can use a `
    ` tag and get the entire form. You could get the values individually from each input tag. Take a quick look at the following documentation link: [Apps Script HTML Service](https://developers.google.com/apps-script/guides/dialogs#custom_dialogs) Although that documentation doesn't show the HTML for input tags. Here is some info about a form [Link to info](https://www.w3schools.com/Tags/tag_input.asp) But don't put an `action` attribute into the form tag. That cause the page to reload.
    – Alan Wells Jun 08 '18 at 14:26

2 Answers2

1

You could create a dialog or sidebar by using the HTML Service. For details see Dialogs and Sidebars in G Suite Documents

Related questions

Rubén
  • 34,714
  • 9
  • 70
  • 166
0

A workaround might be to give the user multiple prompts one after the other.

REVES
  • 36
  • 1
  • 5
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). – GuedesBF Aug 30 '21 at 17:43