Apps script Webapp | Lấy giá trị Input hiển thị lên – Web Get value input field display on web
Giaoan.link chia sẻ đến các bạn một project về “Apps script Webapp | Lấy giá trị Input hiển thị lên – Web Get value input field display on web” khá thú vị. Đây là một ứng dụng nhỏ và bạn có thể thêm nó vào các form nhập liệu của mình.
Chức năng của nó là sẽ lấy giá trị của một trường input để hiển thị ngược lại trên một trường khác của webapp. Dưới đây là code apps script và video demo trên youtube.
Bạn dễ dàn tìm kiếm các project apps script, googlesheet ở đây.
Các project googleapps script ngẫu nhiên
- Tạo hóa đơn trên Google sheet – Gửi email đính kèm hóa đơn pdf – Quản lý url hóa đơn trên danh sách
- Google sheet Ứng dụng theo dõi đơn hàng – Danh sách sản phẩm mua, trạng thái đơn hàng
- Tip on Ms Word Hướng dẫn tạo ngắt trang, xóa ngắt trang đơn lẽ hoặc toàn bộ ngắt trang trên file doc
- Google sheet | Generate QR Codes – Mã hóa nội dung Cell – Thêm hình ở giữa mã QR code
- Google sheet App Script | Tạo custom menu – Xóa tất cả dòng Rỗng trên vùng dữ liệu Nhanh chống
- Google Script Web | From upload file – Kiểm tra trùng lặp – Ghi đè hoặc Tạo phiên bản mới cho file
- Google Script Web | Trang Tìm kiếm nhiều điều kiên riêng lẽ hoặc hết hợp – Print, Xuất file PDF
- Hướng dẫn kiểm tra Bàn phím, Tháo và thay bàn phím mới cho Dell Inspirion 15 3000 series
- Google sheet webapp | Quản lý bán hàng – Chức nằn trả góp, In thông tin
- Ổ C đầy Di chuyển dữ liệu ZALO sang Ổ D hoặc ổ khác một cách dễ dàng Không lo zalo báo đầy ổ đĩa
Mã apps script trang “Code.gs”
function doGet(){
return HtmlService.createTemplateFromFile("index")
.evaluate()
}
Mã apps script trang “Index.html”
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
.container{
border: 2px solid blue;
border-radius: 10px;
width: 600px;
height: 300px;
padding: 5px;
margin-left: auto;
margin-right: auto;
box-shadow: 5px 5px 5px #aaaaaa;
}
.fields{
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 20px;
}
h2{
color: #BA55D3;
text-align: center;
text-shadow: -1px 0 #fff, 0 1px #fff, 1px 0 #fff, 0 -1px #fff;
padding-top: 5px;
}
.input-field{
width: 400px;
height: 20px;
font-size: 15px;
border: 1px solid blue;
outline: none;
border-radius: 15px;
padding: 10px;
}
.contact-inputs:focus{
border: 2px solid #000;
}
.input-field:focus{
border: 2px solid #BA55D3;
}
button{
height: 40px;
padding: 10px 10px;
border: none;
border-radius: 10px;
font-size: 14px;
font-weight: bold;
color: #fff;
background-image: linear-gradient(270deg,#BA55D3,#EE82EE);
cursor: pointer;
}
p{
width: 100%;
font-size: 20px;
font-weight: bold;
text-align: center;
height: 40px;
border: 2px solid red;
border-radius: 10px;
background-color: yellow;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<div class="container">
<h2>Lấy giá trị từ Input hiển thị lên trang web khi click button</h2>
<div class="fields">
<input class="input-field" name="input1" id="input1" type="text" placeholder="Họ tên của bạn">
<button id="btn1">Thực thi</button>
<p id="message"> </p>
</div>
</div>
<script>
const input1 = document.getElementById("input1");
const btn1 = document.getElementById("btn1");
function sendmessage(){
document.getElementById("message").innerHTML = 'Xin chào bạn '+input1.value+ '!';
input1.value = "";
}
btn1.addEventListener("click",sendmessage);
</script>
</body>
</html>