HOW TO FORCE A LINE BREAK ON A JAVASCRIPT CONCATENATED STRING?

Takeshi Okada

Total Post:89

Points:629
Posted by  Takeshi Okada
 2107  View(s)
Ratings:
Rate this:

Hi All!

I'm sending variables to a text box as a concatenated string so I can include multiple variables in on getElementById call.

I need to specify a line break so the address is formatted properly.

document.getElementById("address_box").value =
(title + address + address2 + address3 + address4);
I've already tried \n after the line break and after the variable. and tried changing the concatenation operator to +=.

Thanks in advance!

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How to force a line break on a Javascript concatenated string?

    Hi Takeshi!

    Try this way

    document.getElementById("address_box").value =
    (title + "\n" + address + "\n" + address2 + "\n" + address3 + "\n" + address4);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!