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
- Apps script Webapp | Lấy giá trị Input hiển thị lên – Web Get value input field display on web
- Google sheet Apps script | Todo List and Send mail – Tạo danh sách nhắc việc và gửi mail
- Web App Script | Bộ Icon CSS Rất dễ lập trình cho giao diện webapp
- Google sheet Webapp | Project Quản lý khách hàng – Cập nhật tiến độ sửa chữa
- Google sheet Apps script Webapp | Login form OTP xác minh qua email, Chuyển link cho từng User
- Web App Script CSS JS | Tạo hiệu ứng Click button Nổ tung các mảnh giấy và chuyển link
- Web App Script CSS | Tạo button Liên hệ gồm 3 option đẹp mắt cho trang web
- Web App Script Webapp | Hiệu ứng hoa rơi – Form nhập liệu Gửi nội dung đến email
- Web App Script | Thanh trạng thái Status bar – Giá trị thể hiện theo điểm và label.
- Google sheet Apps script | Data Entry Form – Tự động đọc số tiền thành chữ ở trường input
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>