Reputation: 1335
I have a vertical panel and a button to add. The button allows me to add text boxes to the vertical panel. The name and id of the text box is prefixed with a number (this number is incremented before each text box is added and is initialised with 0).
There is also a button to submit these text boxes. Obviously I add the vertical panel to the handler as a callback element in order to retrieve these added text boxes.
So my parameters of my event (for the submit button being clicked) look something like this:
1tbx=value, 2tbx=value, 3tbx=value, ..., ntbx=value
(where n is a number).
I would like to know the what you guys think would be the least computationally complex way for retrieving the values of the added text boxes from the parameters of the event.
Upvotes: 0
Views: 502
Reputation: 17752
I guess "computationally complex" is not really the point here as all the values are already available locally, and any way you do it will be of the same "complexity".
It's probably easier for you to retrieve these values in a for-loop, probably what you did to create them, e.g.
function handler(e) {
var n = 10; //the amount of text boxes you have
var values = [];
for( var i = 0; i < n; ++i )
values[i] = e.parameter[(i+1)+'tbx'];
//just an example
SpreadsheetApp.openById('example-key').getSheetByName('Sheet1').appendRow(values);
//if you're going to do something on your app (which you'll probably do)
//then you need to return it, e.g. return app;
//but since I'm not doing anything in this example, it's not required.
}
Upvotes: 2