Sometimes I need to copy a long text and use document.write to write the text but the problem is that for every line I have to add a new document.write. for example this wouldn't work -"unteminated string literal" error -: document.write("this is line one. this is line 2. this is line 3."); PHP: so I have to code it like this: document.write("this is line one"); document.write("this is line two"); document.write("this is line three"); PHP: Somebody suggested the following but it has the same problem; var someText = "this is line one. this is line two. this is line three."; document.write(someText); PHP: Is there a command or something that I use and don't need to add that document.write for every single line?
This is so simple, you're going to kick yourself for not thinking of it document.write("this is line one.<br>this is line two.<br>this is line three."); Code (markup):
Thanks for reply but this is not what I wanted. I bring an example, lets say you have this text on a webpage: This is line one. this is line two. ... This is line five hundred. PHP: Now you copythis 500 lines and want to use document.write to print it, you wouldn't want to go all the way an add a "<br>" to the end of each line and delete the carriage return. . .
This won't work... document.write("this is line one. this is line 2. this is line 3."); Code (markup): but this will... document.write("this is line one." + "this is line 2." + "this is line 3."); Code (markup): Also, if you want to add the literal "newline" character just use \n in your string.