Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
Error importing data from textarea in dialog into google spreadsheet

I have a dialog, on which there are some textarea and an Insert button to import data from the textarea into Google spreadsheet. Here is the code:

<td><button style="width:40%" onclick="insert();google.script.run.onEdit();">Insert</button></td>
 

Here is the html code

 function insert() {
        var title = document.getElementById('Qnumber').value;
        var content1 = document.getElementById('content').value;
          var content = replaceContent(content1); 
        var formula1 = document.getElementById('formula').value;
          var formula = replaceFormula(content1,formula1)
        var unit = document.getElementById('unit').value;
        var option1 = document.getElementById('A').value;
        var option2 = document.getElementById('B').value;
        var option3 = document.getElementById('C').value;
        var option4 = document.getElementById('D').value;
        if (document.getElementById('formula').value !=="") {
          google.script.run.enterName1(title,content,formula,unit);
        }
        else {
          google.script.run.enterName2(title,content,option1,option2,option3,option4);
        }
        
      }

Here is the gs code

function enterName1(title,content,formula,unit) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getSheetByName('tests');
  var title = sh.getRange(Number(title)+1,1,1,3).setFormulas([[title, '="'+content+'"', '=round('+formula+';3)'+'&" '+unit+'."']]);
}
function enterName2(title,content,option1,option2,option3,option4){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getSheetByName('tests');
  var title = sh.getRange(Number(title)+1,1,1,3).setFormulas([[title, '="'+content+'"', '=if(column()=3;"'+option1+'";if(column()=4;"'+option2+'";if(column()=5;"'+option3+'";if(column()=6;"'+option4+'"))))']]);
}

When I run the program, the "enterName1" function works and the "enterName2" function does not. Can anyone help me to fix it, thanks.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda