Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!