0

I have created an HTML form (not a Google Form) that populates a Google Sheet. The form has both text inpt and checkboxes (multiples of each.) On the Google Sheet, if a checkbox is checked on the form, it populates the cell in the Sheet as "On".

I am looking to create a Doc using markers to pull the data from the sheet to a printable form, but I need to have a checkmark present instead of the cell data. I suppose I could create additional columns and use an IF array for each instance of the "On" to create a checkmark in the adjacent column to display a checkmark, but I'm sure there's an easier way to do it with a script in the Doc but I have no idea where to start.

All help is greatly appreciated.

1 Answer 1

0

Unicode char#9745 is a "check box check". The formula =CHAR(9745) will produce the checkbox check (as shown in the sample below). But CHAR() is not available in a script.

To convert a Unicode value use String.fromCharCode(9745).

This script is an example of testing for a value of "ON" and, if true, creating a new variable with a value of the checkboxcheck. In this script the variable is then pasted into cell A2 for demonstration purposes.


function myFunction() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName("Sheet1")

  var cellA1 = sheet.getRange("A1").getValue()

  if (cellA1 === "ON"){
    // Logger.log("DEBUG: it is ON")
    var chkbox = String.fromCharCode(9745)
    sheet.getRange("A2").setValue(chkbox)
  }
  else{
    // Logger.log("DEBUG: it is NOT on")
  }
}

SAMPLE OUTPUT

snapshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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