I am trying to convert an Excel UserForm into Google Sheets where the user can create, update or delete entries in existing sheet based on the input form values. I started with selecting a value and display the editable version of it on a textbox. I tried figuring out what is wrong with the value I pass, it is just always displaying the last value and seems not to loop through.

In this example I wanted to fill the form with details from ID 3.


function onOpen(){
  var html = HtmlService.createHtmlOutputFromFile('Index').setSandboxMode(HtmlService.SandboxMode.IFRAME);

function getTextList(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheetText = ss.getSheetByName('Text');
  var sheetTextLastRow = sheetText.getLastRow();
  var sheetTextRange = sheetText.getRange("B2:B" + sheetTextLastRow).getValues();
  return sheetTextRange;


<!DOCTYPE html>
    <base target="_top">
    <select id="selectText" size="5">
    <input type="text" id="newText" placeholder="New Text Replacement">
    <select id="textCategory" placeholder="Category">
    <select id="textLanguage" placeholder="Language">
    <textarea id="textDesc" rows="10" cols="60" placeholder="Description">
         function onSuccess(textValues) {
            var select = document.getElementById("selectText");
            var textOptions = textValues;
            for(var i = 0; i < textOptions.length; i++) {
                var textOpt = textOptions[i];
                var textElement = document.createElement("option");
                textElement.textContent = textOpt;
                textElement.value = textOpt;
                textElement.onclick = function textClick(textDesc){
                    var selectDesc = document.getElementById("newText");   
                    selectDesc.value = textElement.value;                   



  • The values should have been shown with: selectDesc.value = textDesc.target.value;
    – f k
    Commented Aug 8, 2017 at 12:13

1 Answer 1


After all, I was just using a wrong variable. The values should have been shown with:

selectDesc.value = textDesc.target.value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.