2

I'm writing some code to go at the begining of a webpage, which I want a prompt to show up asking visitors a couple of questions (after each question, either the prompt closes, or a new one opens based on the answer). I want the results of these prompts to be emailed to me. What could I do?
Example of my code:

var q = prompt("A five digit number?");
  if (q.length === 5) {
    var pTwo = prompt("Now a 2 digit number?");
    if (pTwo.length === 2) {
      document.write("thank you!");
    } else {
      document.write("Incorrect output");
    }
  } else {
    var con = prompt("Are you sure?");
    if (con === "yes") {
      document.write("thank you anyways");
    } else {
      document.write("Refresh the page to respond.");
    }
  }
Alex
  • 8,461
  • 6
  • 37
  • 49
Heavy Meta
  • 21
  • 2
  • Client-side JavaScript isn't able to communicate directly with email servers. It can only use the [`mailto:` protocol](http://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript) to open an installed email client. Beyond that, there will need to be a server-side layer to mediate, either one you develop or if you find a service that offers a RESTful API. – Jonathan Lonowski Nov 22 '15 at 05:38
  • http://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript – aredzko Nov 22 '15 at 05:39
  • If I were to develop my own, what would be my most efficient option? – Heavy Meta Nov 22 '15 at 05:40
  • @HeavyMeta There isn't really a single answer to that. Most (if not all) languages can be used for server-side web development and will have a reasonable library/API for interacting with mail servers. Though, if you'd like to continue using JavaScript, you can try [Node.js](https://nodejs.org/). – Jonathan Lonowski Nov 22 '15 at 05:47

0 Answers0