CODES
Code.gs
function doGet(e) {
var page = e.parameter.page || "index";
switch(page){
case "about":
// return HtmlService.createHtmlOutputFromFile("About");
var template = HtmlService.createTemplateFromFile("About");
template.username = "Bea Ysabel";
return template.evaluate();
case "contact":
return HtmlService.createHtmlOutputFromFile("ContactUs");
default:
return HtmlService.createHtmlOutputFromFile("Index");
}
}
function getScriptUrl(){
return ScriptApp.getService().getUrl();
}
function getGreetings(){
return "Greetings from the server!";
}
About.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>ABOUT <?= username ?></h1>
<? const name = "Kulas D. Malas"; ?>
<h1> <?= name ?> </h1>
<h2>Display numbers dynamically </h2>
<select>
<? for(i=1;i<=30;i++){ ?>
<option> <?= i ?> </option>
<?}?>
</select>
<h2>Display names from an array dynamically </h2>
<? const students = [
{name:"Pitok Batolata", course:"BSIT"},
{name:"MJ Makyuz", course:"BSN"},
]; ?>
<ul>
<? students.map(function(student){ ?>
<li> <?= `${student.name} ${student.course}` ?> </li>
<?});?>
</ul>
<h2>Access functions from server</h2>
<? const x = getGreetings(); ?>
<h2><?= x ?></h2>
<?!= "<h1>Ambot</h1>" ?>
</body>
</html>
No comments:
Post a Comment