gpt4 book ai didi

html - 如何将 HTML 表单数据发送到 Google 表格?

转载 作者:行者123 更新时间:2023-12-05 05:56:19 25 4
gpt4 key购买 nike

我正在尝试将 HTML 表单数据发送到 google 表格。我已经遵循了几个教程,但无法将表单数据发送到谷歌表格。我成功部署了谷歌脚本,复制了链接并链接到 HTML 但没有结果。我实际上在这里缺少什么?寻求您的指导。

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Form</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

</head>

<body>
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="https://www.freeiconspng.com/uploads/tumblr-logo-icon-9.png" alt="" width="30" height="24" class="d-inline-block align-text-top"> Test Form
</a>
</div>
</nav>

<div class="container">

<form class="row g-3" method="POST" autocomplete="off" name="test_form">

<select class="form-select form-select-lg mb-3" name="title" aria-label=".form-select-lg example">
<option selected>Open this select menu</option>
<option value="1">Mr.</option>
<option value="2">Miss</option>
<option value="3">Mrs.</option>
</select>

<div class="container">
<div class="row g-2">
<div class="col-6">
<div class="col">
<input type="text" class="form-control" name="firstname" placeholder="First name" aria-label="First name">
</div>
</div>
<div class="col-6">
<div class="col">
<input type="text" class="form-control" name="lastname" placeholder="Last name" aria-label="Last name">
</div>
</div>
<div class="col-6">
<div class="col">
<input type="email" class="form-control" name="email" placeholder="Email" aria-label="Email">
</div>
</div>
<div class="col-6">
<div class="col">
<input type="text" class="form-control" name="telephone" placeholder="Telephone" aria-label="Telephone">
</div>
</div>
</div>
</div>

<div class="form-floating">
<textarea class="form-control" name="comment" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
<label for="floatingTextarea2">Comments</label>
</div>

<div class="col-12">
<button class="btn btn-primary" type="submit" name="submit" value="send message">Submit form</button>
</div>
</form>

<script type="text/javascript">
const scriptURL = 'https://script.google.com/macros/s/AKfycbyWrl6cQr8C6PatE2tTZ3kJWi0lInw4rgu4nRBB8AqY3X7GDJ_6387yOtqsBJSjdV96og/exec'
const form = document.forms['google-sheet']

form.addEventListener('submit', e => {
e.preventDefault()
fetch(scriptURL, {
method: 'POST',
body: new FormData(form)
})
.then(response => alert("Thanks for Contacting us..! We Will Contact You Soon..."))
.catch(error => console.error('Error!', error.message))
})
</script>
<!-- <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script> -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>

</div>
</body>

</html>

最佳答案

您可以按照 here 中的教程进行操作.

确保添加 Add a new project triggerPublish the project as a web appInput your web app URL carefully.

关于html - 如何将 HTML 表单数据发送到 Google 表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69182651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com