Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Created August 23, 2020 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndthanh/574eb112f7f1cbec11efc4e881d5c324 to your computer and use it in GitHub Desktop.
Save ndthanh/574eb112f7f1cbec11efc4e881d5c324 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Bulma!</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css">
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">
Add new Customer
</h1>
<div class="field">
<div class="control">
<input id="input-id" class="input is-primary" type="text" placeholder="ID">
</div>
</div>
<div class="field">
<div class="control">
<input id="input-first-name" class="input is-primary" type="text" placeholder="First Name">
</div>
</div>
<div class="field">
<div class="control">
<input id="input-last-name" class="input is-primary" type="text" placeholder="Last Name">
</div>
</div>
<div class="field">
<div class="control">
<input id="input-email" class="input is-primary" type="text" placeholder="Email">
</div>
</div>
<div class="buttons">
<button id="btnSaveCustomer" class="button is-primary">Save customer</button>
</div>
</div>
</section>
<script>
const btnSave = document.getElementById("btnSaveCustomer");
btnSave.addEventListener("click", themDuLieu);
function themDuLieu() {
const inputId = document.getElementById("input-id").value;
const inputFirstName = document.getElementById("input-first-name").value;
const inputLastName = document.getElementById("input-last-name").value;
const inputEmail = document.getElementById("input-email").value;
if(inputId.length == 0 || inputFirstName.length == 0 || inputLastName.length == 0 || inputEmail.length == 0) {
google.script.run.errMessage();
} else {
const data = {
id: inputId,
firstName: inputFirstName,
lastName: inputLastName,
email: inputEmail
}
google.script.run.dienDuLieu(data);
inputId = "";
inputFirstName = "";
inputLastName = "";
inputEmail = ""
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment