NoroffFEU / musikkforandrerliv.no

The Unlicense
8 stars 3 forks source link

Merge pull request #481 from NoroffFEU/main #490

Open ukonuidika opened 1 month ago

ukonuidika commented 1 month ago

Contact form JS file #180

(1) Firstly I have created a JS file for the contact form.

(2) I also created a html file for this purpose as well.

(3) I also created a php file to help send the mail to the saver.

Below is my JS for Contact form.

document.addEventListener( "DOMContentLoaded", function () { var contactForm = document.getElementById ("contact-form"); var formMessages = document.getElementById ("form-messages"); contactForm.addEventListener("submit", function (event){ event.preventDefault(); var formData = new formData(contactForm); fetch("contact.php",{ method: "POST", body: formData })

        .then(function(response) {
            return response.json();
        })

        .then(function(data) {
            formMessages.textContent = data.message;
            formMessages.style.display = "block";
            if (data.success) {
                formMessages.style.color = "green";
                contactForm.reset();
            }
            else {
                formMessages.style.color = "red";
            }
        })

        .catch(function(error) {
            console.error("Error", error);
        });

    });

});
netlify[bot] commented 1 month ago

Deploy Preview for dazzling-melomakarona-fe8d9f ready!

Name Link
Latest commit 30fb4056c2f0a2aeb229ebc872e58a5a74cab092
Latest deploy log https://app.netlify.com/sites/dazzling-melomakarona-fe8d9f/deploys/661d2a97bbc6c10007daf995
Deploy Preview https://deploy-preview-490--dazzling-melomakarona-fe8d9f.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 1 month ago

Deploy Preview for snazzy-moonbeam-86e465 ready!

Name Link
Latest commit 30fb4056c2f0a2aeb229ebc872e58a5a74cab092
Latest deploy log https://app.netlify.com/sites/snazzy-moonbeam-86e465/deploys/661d2a9752e4e70008e8a176
Deploy Preview https://deploy-preview-490--snazzy-moonbeam-86e465.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.