Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
How to submit selected responses along with the form?

I have a questionnaire that the user goes through step by step and finally submits the form. I want the form where the user submits their name and phone number to be sent along with the selected responses. How can I add the user's selected responses to the form and submit them?

//An example of a question where the user selects a gender
function appGender() {
  scrollDown();
  $(".chat-content-list").append(
    '<div><span class="chooseGenderM">Male</span></div><div class="chat-content-buttons-gender-block"><span class="chooseGenderW">Woman</span></div>'
  );
}

function genderNext() {
  $(".chooseGenderM").click(() => {
    document.querySelector(".chat-content-buttons-gender").style.display =
      "none";
    myMassange("Male");
  });
  $(".chooseGenderW").click(() => {
    document.querySelector(".chat-content-buttons-gender").style.display =
      "none";
    myMassange("Woman");
  });
}

//submit form
const form = document.getElementById("order_form");
form.addEventListener("submit", formSend);

async function formSend(e) {
  e.preventDefault();

  let error = formValidate(form);
  let formData = new FormData(form);

  if (error === 0) {
    let response = await fetch("sendmail.php", {
      method: "POST",
      body: formData,
    });
    if (response.ok) {
      let result = await response.json();
      alert(result.message);
      formPreview.innerHTML = "";
      form.reset();
    }
  }
}

//sendmail.php

//Body
if (trim(!empty($_POST['name']))) {
    $body .= '<p><strong>Name:</strong>' . $_POST['name'] . '</p>';
}
if (trim(!empty($_POST['phone']))) {
    $body .= '<p><strong>Phone:</strong>' . $_POST['phone'] . '</p>';
}

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!