Because I have a Google spreadsheet workbook with so many sheets that they are not all visible in the pulldown on the bottom left side of the spreadsheet workbook, I am attempting to modify the code at "How to get the list of all sheet in a dropdown list in a sidebar" from a standalone script to a bound script in order to be able to see a longer list. Also, I do not want my list in a dropdown. I want it simply as a bulleted list.
I am getting a malformed HTML error that I assume is being generated from within the scriplet. (See code below.) Any ideas what is going wrong with this code.
HTML
<html>
<head>
<base target="_top">
</head>
<body>
<select name="Sheets List" onchange="listSheets()")>
<? var sheets=spreadsheet.getSheets(); ?>
<? for(var i=0;i<sheets.length;i++) { ?>
<option value=<?=sheets[i].getName()?>> <?= sheets[i].getName()?></option>
<? } ?>
</select>
<script>
function listSheets(){
var name=document.getElementsByName("Sheets List")[0].value;
google.script.run.goToSheet(name);
};
</script>
</body>
</html>
GS
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Custom')
.addItem('Sheets List', 'sheetsList')
.addToUi();
function sheetsList(){
var html = HtmlService.createHtmlOutputFromFile('sheets').evaluate
.setTitle('Sheets in this Workbook')
.setWidth(300);
SpreadsheetApp.getUi()
.showSidebar(html);
}
}
Error Message
Message details Malformed HTML content: > function listSheets(){ var name=document.getElementsByName("Sheets List")[0].value; google.script.run.goToSheet(name); }; .
)
here:listSheets()"
)>
– TheMaster