有多种方法可以将html表单数据添加到电子表格,但可以将amp-form数据发送到电子表格。我尝试使用这种简单的方法https://www.codeproject.com/Tips/721795/Store-your-form-data-in-Google-Spreadsheet
这是表格
<amp-script width="1" height="1" script="webSocketDemo"> </amp-script>
<form name="contact">
<div class="fieldset">
<input class="input-label" type="text" name="Name" data-form-field="Name" placeholder="Name" required="" >
<input class="input-label" type="phone" name="Mobile" data-form-field="Phone" placeholder="Phone" required="" >
<input class="input-label" type="email" name="Email" data-form-field="Email" placeholder="Email" required="" >
<select name="Course">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
</select>
</div>
<div class="align-center">
<button type="submit" class="btn btn-lg btn-primary display-7 display-6" id="ButtonSubmit" onclick="postContactToGoogle()" >Submit</button>
</div>
</form>
这是js
function postContactToGoogle() {
var email = $('#Email').val();
var name = $('#Name').val();
var mobile = $('#Mobile').val();
var course = $('#Course').val();
$.ajax({
url: "https://docs.google.com/forms/u/0/d/e/1FAIpQLSe430g_JJ5AjWF-VZRfo7xRAhUBB8a2tUcFIg8afBIgCsQh3Q/formResponse",
data: {
"entry.142451696": email,
"entry.929775569": name,
"entry.1001360739": mobile,
"entry.2049253971": course
},
type: "POST",
dataType: "xml",
statusCode: {
0: function () {
window.location.replace("ThankYou.html");
},
200: function () {
window.location.replace("ThankYou.html");
}
}
});
}
那里有合适的解决方案吗?