I have a google sheets field that will have a yes or no value. When I render an HTML form that I use I want to populate the "checked" value on the HTML input tag based on what is in the google sheets but cannot seem to get the HTML and script to work so any help is greatly appreciated.
Here is what I have :
In the google app script I have a function to show the HTML form
var html = HtmlService.createHtmlOutputFromFile("addUserLeadScore").setWidth(500).setHeight(550);
In the HTML file I load the form and call the getData function
window.onload = function LoadFormWithData()
{
google.script.run.withSuccessHandler(showData).getData();
}
Here is the getData
function getData(){
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Template");
var data = sheet.getRange(iRow, iCol, iNumRows, iNumCols).getValues();
return data;
}
And here is the HTML to build the radio buttons
<div id="firstAndLast"></div>
<td id="firstAndLastTd">
<center>Prospect provided a first <b>AND</b> last name </center>
<input type="radio" name="firstAndLast" value="Yes"> Yes <br>
<input type="radio" name="firstAndLast" value="No"> No <br>
</td>
But how do I do it so that if data[0][1] = "yes" :
<input type="radio" name="firstAndLast" value="Yes" checked>
instead of
<input type="radio" name="firstAndLast" value="Yes" checked>