Quick actions

cmd+k|ctrl+k

Navigation

Languages

send email

Snippet info

Language

JavaScript

Visibility

public

Author

riki.whyudi

Created

2022-10-12T10:10:38.439474Z

Updated

2022-10-12T10:10:38.439474Z

function ShowData() {
  console.log("hello boss");
  const name = document.getElementById("input-name").value;
  const email = document.getElementById("input-email").value;
  const phone = document.getElementById("input-phone").value;
  const subject = document.getElementById("input-subject").value;
  const message = document.getElementById("input-message").value;

  const emailReceiver = "[email protected]";
  const msg = `Hello, \nMy name is ${name} \nHandphone: ${phone} \n\n${message} \n\n\n`;

  if (
    name !== "" &&
    email !== "" &&
    phone !== "" &&
    subject !== "" &&
    message !== ""
  ) {
    const a = document.createElement("a");
    a.href = `mailto: ${emailReceiver}?subject=${encodeURIComponent(
      subject
    )}&body=${encodeURIComponent(msg)}`;
    a.click();
  } else {
    alert("Tolong isi semua form dengan baik..");
  }
}
INFO