Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda