简体   繁体   English

将日期从 html 表单发送到 Google 日历等

[英]Send date from html form to Google calendar, etc

This is a noob question.这是一个菜鸟问题。 What I'd like to do is set up a birthday party reservation website that has people fill out a form: yes/ no will attend, name, email.我想做的是建立一个生日聚会预订网站,让人们填写表格:是/否将参加,姓名,email。 After the form is filled out for 'will attend' I'd like to have a popup modal that has the option to 'add to your calendar: Google, iCal, etc.'填写“将参加”的表格后,我希望有一个弹出模式,可以选择“添加到您的日历:Google、iCal 等”。 Is this possible in an html form (javascript/ ajax)?这在 html 形式(javascript/ajax)中是否可行? I know it can be done in WordPress.我知道它可以在 WordPress 中完成。 Thank you for any help/ suggestions.感谢您的任何帮助/建议。

Here is a very basic idea of what you could do.这是您可以做什么的一个非常基本的想法。 I put the form in the console using the answer here: https://stackoverflow.com/a/47188324/12946266 you will need to use php to operate on this form most likely, but I can't use that here.我使用此处的答案将表单放入控制台: https://stackoverflow.com/a/47188324/12946266您最有可能需要使用 php 来操作此表单,但我不能在这里使用它。

 const form = document.querySelector('form'); document.getElementById("myForm").addEventListener("submit", function(event) { event.preventDefault(); var values = Object.values(form).reduce((obj, field) => { if(field.type=='radio'){ obj[field.name] = field.checked; }else{ obj[field.name] = field.value; } return obj }, {}) console.log(values); });
 <form id="myForm" action="/action_page.php"> First name: <input type="text" name="fname" value=""><br> Last name: <input type="text" name="lname" value=""><br> email: <input type="text" name="email" value=""><br> <input type="radio" id="attending" name="attendance" value="attending"> <label for="attending">attending</label> <br> <input type="submit" value="Submit"><br> </form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM