From be50c677b538e41907f2e75862c1b233a908ffe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Torben=20B=C3=B6hnke?= <torben.boehnke-makerspace@rub.de>
Date: Fri, 25 Oct 2024 14:12:01 +0200
Subject: [PATCH] update t35t

---
 docs/t35t.md           | 32 ++++++++++++++++++++++----------
 public/t35t/index.html | 32 ++++++++++++++++++++++----------
 2 files changed, 44 insertions(+), 20 deletions(-)

diff --git a/docs/t35t.md b/docs/t35t.md
index 30010a86d..363b2c4d6 100644
--- a/docs/t35t.md
+++ b/docs/t35t.md
@@ -70,15 +70,27 @@ Alternativ kannst Du uns auch eine E-Mail an [makerspace@rub.de](mailto:makerspa
 </form>
 
 <script>
-document.querySelector('form').addEventListener('submit', function(e) {
-    var formattedMessage = 
-        "Vorname: " + document.querySelector('input[name="vorname"]').value + "\n" +
-        "Nachname: " + document.querySelector('input[name="nachname"]').value + "\n" +
-        "E-Mail: " + document.querySelector('input[name="email"]').value + "\n" +
-        "Telefonnummer: " + document.querySelector('input[name="tel"]').value + "\n" +
-        "Nachricht:\n" + document.querySelector('textarea[name="nachricht"]').value + "\n" +
-        "Einverständnis Datenschutz: " + (document.querySelector('input[name="data-privacy"]').checked ? 'Ja' : 'Nein');
-    
-    document.getElementById('formatted_message').value = formattedMessage;
+document.addEventListener('DOMContentLoaded', function() {
+    document.getElementById('Kontaktformular').addEventListener('submit', function(e) {
+        // Collect form values
+        var vorname = document.querySelector('input[name="vorname"]').value;
+        var nachname = document.querySelector('input[name="nachname"]').value;
+        var email = document.querySelector('input[name="email"]').value;
+        var tel = document.querySelector('input[name="tel"]').value;
+        var nachricht = document.querySelector('textarea[name="nachricht"]').value;
+        var dataPrivacyChecked = document.querySelector('input[name="data-privacy"]').checked ? 'Ja' : 'Nein';
+
+        // Build the formatted message
+        var formattedMessage = 
+            "Vorname: " + vorname + "\n" +
+            "Nachname: " + nachname + "\n" +
+            "E-Mail: " + email + "\n" +
+            "Telefonnummer: " + tel + "\n" +
+            "Nachricht:\n" + nachricht + "\n" +
+            "Einverständnis Datenschutz: " + dataPrivacyChecked;
+
+        // Set the value of the hidden field
+        document.getElementById('formatted_message').value = formattedMessage;
+    });
 });
 </script>
\ No newline at end of file
diff --git a/public/t35t/index.html b/public/t35t/index.html
index f7fcacd04..f08b7f005 100644
--- a/public/t35t/index.html
+++ b/public/t35t/index.html
@@ -714,16 +714,28 @@ Alternativ kannst Du uns auch eine E-Mail an <a href="mailto:makerspace@rub.de">
 </form>
 
 <script>
-document.querySelector('form').addEventListener('submit', function(e) {
-    var formattedMessage = 
-        "Vorname: " + document.querySelector('input[name="vorname"]').value + "\n" +
-        "Nachname: " + document.querySelector('input[name="nachname"]').value + "\n" +
-        "E-Mail: " + document.querySelector('input[name="email"]').value + "\n" +
-        "Telefonnummer: " + document.querySelector('input[name="tel"]').value + "\n" +
-        "Nachricht:\n" + document.querySelector('textarea[name="nachricht"]').value + "\n" +
-        "Einverständnis Datenschutz: " + (document.querySelector('input[name="data-privacy"]').checked ? 'Ja' : 'Nein');
-
-    document.getElementById('formatted_message').value = formattedMessage;
+document.addEventListener('DOMContentLoaded', function() {
+    document.getElementById('Kontaktformular').addEventListener('submit', function(e) {
+        // Collect form values
+        var vorname = document.querySelector('input[name="vorname"]').value;
+        var nachname = document.querySelector('input[name="nachname"]').value;
+        var email = document.querySelector('input[name="email"]').value;
+        var tel = document.querySelector('input[name="tel"]').value;
+        var nachricht = document.querySelector('textarea[name="nachricht"]').value;
+        var dataPrivacyChecked = document.querySelector('input[name="data-privacy"]').checked ? 'Ja' : 'Nein';
+
+        // Build the formatted message
+        var formattedMessage = 
+            "Vorname: " + vorname + "\n" +
+            "Nachname: " + nachname + "\n" +
+            "E-Mail: " + email + "\n" +
+            "Telefonnummer: " + tel + "\n" +
+            "Nachricht:\n" + nachricht + "\n" +
+            "Einverständnis Datenschutz: " + dataPrivacyChecked;
+
+        // Set the value of the hidden field
+        document.getElementById('formatted_message').value = formattedMessage;
+    });
 });
 </script></div>
 
-- 
GitLab