首页 > 解决方案 > 如何将两个 html 表单与一个谷歌表格链接?

问题描述

<script>
							  const scriptURL = ''
							  const form = document.forms['submit-to-google-sheet']

							  form.addEventListener('submit', e => {
							    e.preventDefault()
							    fetch(scriptURL, { method: 'POST', body: new FormData(form)})
							      .then(response => console.log('Success!', response))
							      .catch(error => console.error('Error!', error.message))
							  })
							</script>
<div class="col-md-5">
						<div class="background-form">
							<form id="contact" action="" method="post">
								<fieldset>
									<input placeholder="Your name" name="Name" type="text" tabindex="1" required >
								</fieldset>
								<fieldset>
									<input placeholder="Your Email Address" name="Email" type="email" tabindex="2" required>
								</fieldset>
								<fieldset>
									<input placeholder="Your Phone Number" name="Phone_No" type="tel" tabindex="3" required>
								</fieldset>
								<fieldset>
									<select name="Category_Interested" title="Center" class="form-control" required>
										<option value="">&nbsp;Category Interested In</option>
										<option value="Modular Furnitur">Modular Furniture</option>
										<option value="Home Furnishing">Home Furnishing</option>
										<option value="Kitchen Appliances">Kitchen Appliances</option>
									</select>
								</fieldset>
								<fieldset>
									<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Submit</button>
								</fieldset>
								<div class="callus">
									<a href="tel: +91 9711600069"><span class="call-span">Call Us: +91 9711600069</span></a>
								</div>
							</form>
						</div>
						<section id="fixed-form-container">
							<div class="button blink">
								<span>Free Enquiry</span>
							</div>
							<div class="body">
								<form name="submit-to-google-sheet">
									<div class="form-group">
										<label for="name">Name:</label>
										<input type="name" class="form-control" id="name" name="Name">
									</div>
									<div class="form-group">
										<label for="contact">Phone No.:</label>
										<input type="tel" name="Phoneno" class="form-control" id="contact">
									</div>
									<div class="form-group" style="margin-top: -38px;">
									    <label for="email">Email address:</label>
									    <input type="email" class="form-control" id="email" name="email">
									</div>
									<div class="form-group">
										<label for="category">Category Interested In</label>
										<select name="category" title="Center" class="form-control" required>
											<option value="">&nbsp;Category Interested In</option>
											<option value="Modular Furnitur">Modular Furniture</option>
											<option value="Home Furnishing">Home Furnishing</option>
											<option value="Kitchen Appliances">Kitchen Appliances</option>
										</select>
									</div>
									<button type="submit" class="btn btn-default">Submit</button>
									<div class="callus callus-phone">
										<a href="tel: +91 9711600069"><span class="call-phone-span call-span">Call Us: +91 9711600069</span></a>
									</div>
								</form>
							</div>
							
						</section>
					</div>

我正在尝试将使用 HTML 创建的两种表单与一个google sheet. 如果我尝试添加两个SrciptURLs,则会显示错误。我希望这两种形式的数据都可以在一个中看到Google Sheet。那可能吗?如果是,那么如何?这些是表格以及我添加的用于将其链接到 Google 表格的脚本。当我填写条目并在两个表格中提交时没有错误,但在 Google 表格中只能看到一个表格的详细信息。

标签: javascript

解决方案


推荐阅读