0

I have searched a lot on how to do this, but none of the solutions have been successful in my case.

I have built a very simple JS form which will generate text ready to copy and paste straight into an email.

My only problem now is getting that text appear exactly as I want it in the email (i.e. multi line).

Does anyone have any suggestions based on my code below?

Not duplicate. I have already read/tried the examples in the other post and none of them work. Hence why I am creating a new question specifically for my code.

function myFunction3() {
    var b, text;

    b = document.getElementById("type").value;

    if (b === "rfi") {
        text = "This is an RFI email";
    } else {
        text = "This is a bank details request email";
    }
    document.getElementById("demo3").innerHTML = text;
}

The HTML part is below:

<p id="demo3"></p>
Chris
  • 123
  • 8
  • 4
    Where is the multi line string you are talking about ? – klugjo Apr 06 '18 at 01:22
  • Have you tried using a textarea instead of a textbox? – Edwin Chua Apr 06 '18 at 01:23
  • Hi, it's just the text in the if/else statements. I didn't actually include the full email I want. I should have. – Chris Apr 06 '18 at 01:24
  • The *question* is still a duplicate whether or not it worked for *you*. If you are having problems getting the answer from the other question to work, you should link to the other answer as a reference and demonstrate that you have tried it in your question with code. Then this question won't be considered a duplicate because you are asking a question about the other answer. Make sure you provide enough context here so the question stands on its own if the other one gets changed or deleted. – NightOwl888 Apr 06 '18 at 06:57

1 Answers1

0

var a = "First line.";
var b = "Second line.";
console.log(a + "\n" + b);

var a = "First line.";
var b = "Second line.";
document.getElementById("test").innerHTML = a + "<br/>" + b;
<div id="test"></div>
Igor
  • 15,833
  • 1
  • 27
  • 32