title: How to get date text input in custom HTML dialogue box to load with a value from Google Sheets?
body: <p>I'm trying to change the value of a text input on a custom (HTML) dialogue box in Google Sheets to equal a value on my Google Sheet. How can I achieve this?    </p>
  
  <p>I'm aware of the correct format of the date that needs to be applied in order to set the .value of the text input. I can use the 'Utilities' service in the .gas. </p>
  
  <p>I've tried using the <code>onload="getDate()"</code> event to run a function that sets the value using <code>var date = new Date()</code> in <code>getDate()</code> and not get the values from the sheet directly but that doesn't seem to work. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;base target="_top"&gt;
  
      &lt;style&gt;
      label {font-family: verdana;}
  
      body {
      border: 1px solid powderblue;
      padding: 30px;
      }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body  onload="getDate()"&gt;
  
  &lt;form id="myForm"&gt;
    &lt;label&gt;Task Number:&lt;/label&gt;&lt;br&gt;
    &lt;input type="text" name="taskNumber" value=""&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Task Date:&lt;/label&gt;&lt;br&gt;
    &lt;input type="date" name="taskDate" value="" id="demo" &gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Customer Name:&lt;/label&gt;&lt;br&gt;
    &lt;input type="text" name="customerName" value=""&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Customer Site:&lt;/label&gt;&lt;br&gt;
    &lt;input type="text" name="customerSite" value=""&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Status:&lt;/label&gt;&lt;br&gt;
    &lt;select name="status"&gt;
    &lt;option value="NOSTATUS"&gt;Choose&lt;/option&gt;
    &lt;option value="ON HOLD"&gt;ON HOLD&lt;/option&gt;
    &lt;option value="SCHEDULED"&gt;SCHEDULED&lt;/option&gt;
    &lt;option value="RESCHEDULE"&gt;RESCHEDULE&lt;/option&gt;
    &lt;option value="WORK IN PROGRESS"&gt;WORK IN PROGRESS&lt;/option&gt;
    &lt;/select&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Status Date:&lt;/label&gt;&lt;br&gt;
    &lt;input type="date" name="statusDate" value=""&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Location:&lt;/label&gt;&lt;br&gt;
    &lt;input type="text" name="location" value=""&gt;
    &lt;br&gt;&lt;br&gt;
     &lt;label&gt;Description:&lt;/label&gt;&lt;br&gt;
    &lt;input type="text" name="description" value=""&gt;
    &lt;br&gt;&lt;br&gt;
    &lt;input type="button" style="font-family: verdana;" value="Submit" onclick="uploadTask()"&gt;
  
  &lt;/form&gt; 
  
    &lt;script&gt;
    function success(msg) {
      alert(msg);
    }
  
    function uploadTask(){
      var form = document.getElementById("myForm").elements;
      var obj ={};
      for(var i = 0 ; i &lt; form.length ; i++){
          var item = form.item(i);
          obj[item.name] = item.value;
      }
      google.script.run
      .withSuccessHandler(success)
      .uploadTask(obj);
  
      google.script.host.close();
    }
  
    function getDate(){
    var ss = SpreadsheetApp.openById('1CtH3uNeSiJcRd_ZKE3iWp7TEtAO_B7uCNatGJ7rHMeg');
    var monthly = ss.getSheetByName('MONTHLY');         
    var date = monthly.getRange(1, 1).getValue(); //The value of A:1 = 10/12/2000 date 
  
    date = Utilities.formatDate(date, Session.getScriptTimeZone(), "YYYY-MM-dd")
  
    document.getElementById("demo").value = date;
  
    }
    &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>