<!DOCTYPE html>>
<html>
<head>
<meta name="viewprot" content="width=divice-width, initial-scale=0.1">
<title>Subscribe Form to Google Sheet - Code Name Is Adi</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="hero">
<h3>Coming Soon</h3>
<h1>OurBrand New<br>Website Is On It's Way</h1>
<p>Subscribe For More Details</p>
<form name="submit-to-google-sheet">
<input type="email" name="Email" placeholder="Your Email Id" required>
<button type="submit"><img src="send-icon.png"width="30px"></button>
</form>
<span id="msg"></span>
</div>
<script>
const scriptURL = 'https://script.google.com/macros/s/AKfycbwEq2iJ8769Nz_r8ebDCYMknjRWu-HEIxou_xIuHUv3eQR-RZpENHWr2uEl2pL1J-TL/exec'
const form = document.forms['submit-to-google-sheet']
const msg = document.getElementById(msg)
form.addEventListener('submit', e => {
e.preventDefault()
fetch(scriptURL, { method: 'POST', body: new FormData(form)})
.then(response => {
msg.innerHTML = "Thank You For Subscribing!"
setTimeout(function(){
msg.innerHTML = ""
},5000)
form.reset()
})
.catch(error => console.error('Error!', error.message))
})
</script>
</body>
</html>
*
{
margin: 0;
padding: 0;
font-family: 'poppins',sans-serif;
box-sizing: border-box;
}
.hero
{
width: 100%;
height: 100vh;
background-image: linear-gradient(rgba(0,0,0,0.8), rgba(0,0,0,0.8)),url(background.png);
background-size: cover;
background-position: center;
padding: 10px 10%;
color: #fff;
}
.hero h3
{
margin-top: 15%;
font-weight: 400;
font-size: 30px;
}
.hero h1
{
margin-top: 30px;
font-size: 50px;
}
.hero p
{
margin: 10px 0 50px;
}
form
{
background: #fff;
display: flex;
width: fit-content;
}
form input
{
border: 0;
outline: none;
padding: 10px 20px;
height: 70px;
width: 400px;
font-size: 16px;
}
form button
{
background: #61b752;
border: none;
outline: none;
height: 70px;
width: 100px;
cursor: pointer;
}
span
{
color: #61b752;
margin-top: 10px;
display: block;
}
0 Comments
If your having doubt please let me know