Good day! I need your help, gentlemen.
Background:
The site has a form, you need to make it so that:
- The form sent data to Google form (beautifully forming in the tables).
- In the form there is a field "e-mail", after sending, the user should be sent a letter in the mail informing about the registration.
- After registering, the user must somehow be informed that the form works and does not simply refresh the page after clicking the "send" button.
With the first paragraph, I figured out, on the Internet a lot of information about this. The form sends data to the tables.
<form class="contact_form form" action="https://docs.google.com/forms/d/e/bl-bla-bla/formResponse" method="post"> <ul> <li><input placeholder="Π’Π΅ΠΌΠ°0" type="text" name="entry.82222974"></li> <li><input type="text" placeholder="E-mail" name="mail" name="entry.1824090412"></li> <li><input type="text" placeholder="Π’Π΅ΠΌΠ°1" name="entry.1638850810"></li> <li><input type="text" placeholder="Π’Π΅ΠΌΠ°2" name="entry.856932552"></li> <li><input type="text" placeholder="Π’Π΅ΠΌΠ°3" name="entry.1016239961"></li> <li><input type="text" placeholder="Π’Π΅ΠΌΠ°4" name="entry.1906109374"></li> <li><button class="submit" type="submit"/>ΠΡΠΏΡΠ°Π²ΠΈΡΡ</button></li> </ul> <p class="msgs"></p> </form> I figured out the second item, too. I used this manual .
Separately, everything works well, but as soon as I put everything together, sending into Google form stops working.
I understand that it does not work because of this script, which is responsible for sending the letter and displaying the message under the form Thank you for registration! because It works through AJAX and does not reload the page, and sending data to the Google table is done by reloading the page.
$(document).ready(function () { $("form").submit(function () { // ΠΠΎΠ»ΡΡΠ΅Π½ΠΈΠ΅ ID ΡΠΎΡΠΌΡ var formID = $(this).attr('id'); // ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΡΠ΅ΡΡΡΠΊΠΈ ΠΊ ΠΈΠΌΠ΅Π½ΠΈ ID var formNm = $('#' + formID); var message = $(formNm).find(".msgs"); // ΠΡΠ΅Ρ ΠΊΠ»Π°ΡΡ .msgs Π² ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΠΎΡΠΌΠ΅ ΠΈ Π·Π°ΠΏΠΈΡΡΠ²Π°Π΅ΠΌ Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ var formTitle = $(formNm).find(".formTitle"); // ΠΡΠ΅Ρ ΠΊΠ»Π°ΡΡ .formtitle Π² ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΠΎΡΠΌΠ΅ ΠΈ Π·Π°ΠΏΠΈΡΡΠ²Π°Π΅ΠΌ Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ $.ajax({ type: "POST", url: 'sendmail/mail.php', data: formNm.serialize(), success: function (data) { // ΠΡΠ²ΠΎΠ΄ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ ΠΎΠ± ΡΡΠΏΠ΅ΡΠ½ΠΎΠΉ ΠΎΡΠΏΡΠ°Π²ΠΊΠ΅ message.html(data); formTitle.css("display","none"); setTimeout(function(){ //$(formNm).css("display","block"); $('.formTitle').css("display","block"); $('.msgs').html(''); $('input').not(':input[type=submit], :input[type=hidden]').val(''); }, 3000); }, error: function (jqXHR, text, error) { // ΠΡΠ²ΠΎΠ΄ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ΅ ΠΎΡΠΏΡΠ°Π²ΠΊΠΈ message.html(error); formTitle.css("display","none"); // $(formNm).css("display","none"); setTimeout(function(){ //$(formNm).css("display","block"); $('.formTitle').css("display","block"); $('.msgs').html(''); $('input').not(':input[type=submit], :input[type=hidden]').val(''); }, 3000); } }); return false; }); }); Now the most important question is how and what needs to be changed in this script, so that the letter is sent, the text is output and the data is recorded in a Google form? Can it be replaced by sending a letter and outputting text to something else?
I would be very grateful for your reply, as I have been racking my brains for half a day already.