2

Good morning and thank you in advance for the help. I am a noobi at java/gas scripting so any help is appreciated.

On a google spreadsheet I have a custom menu that launches a small html menu that I would like to be able to launch various web pages from. The actual addresses are variable. I have set those as Keys with the property service when the page launches.

Here is the html code (taken from another example and trying to adapt)"

<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<script type="text/javascript">

var myArr = ["Peter", "Paul", "Tony", "Adam"];
function display(name) {
var accScriptPageLinkID= PropertiesService.getScriptProperties().getProperty('scriptPageLinkAdd');
Logger.log(accScriptPageLinkID)
alert(name);
}

for(var i = 0; i < 4; i ++) {
document.write('<input type="button" onclick="display(this)" name="'+  myArr[i] + '" value="'+ myArr[i] +'">'); // Will log Peter, Paul..
}
</script>
</body>
</html>

I need to modify the above code so that when the button Peter is pressed it opens the Script Page linked under the Property Service Key 'scriptPageLinkAdd'.

Or if there is an easier way to create a dynamic html page for my menu that is linked to cells in the google spreadsheet, please advise.

Mike

1 Answer 1

2

PropertiesService (and Logger too) are server-side AppsScript classes - they can't be invoked directly from the client side (your html page). To invoke them on the server side from your html page you must use google.script.run.withSuccessHandler(clientSideFunctionToProcessReturnedData).someServerSideFunction() which can return some data back to your html page. Learn more about HtmlService and communicating with the server here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.