I have to create a form for work. It involves some JavaScript. I have to use a textarea field, but the problem is that I need the output to look EXACTLY like the Input that someone would type into the textarea field. This is what I am talking about: <html> <head> <title>Textarea problem</title> <SCRIPT language= "javascript"> function DispMsg(text1) { document.write("The text you submitted is: <br>" +text1) document.textform.reset() } </SCRIPT> </head> <BODY> <FORM NAME=textform> <h2><b>Input Textarea Form</b></h2> <br> <TEXTAREA NAME="text1" rows="10" cols="40" TYPE="text">COPY/PASTE HERE</TEXTAREA> <INPUT NAME="submit" TYPE=Button VALUE="Submit" OnClick="DispMsg(form.text1.value)"> </FORM> </BODY> </html> So, if you type into the textarea field: The dog is brown. The dog is brown. The dog is brown. The dog is brown. It will output into a single line: The dog is brown. The dog is brown. etc.. How do I get it to output into 4 separate lines as above?
Try this one.. <html> <head> <title>Textarea problem</title> <SCRIPT language= "javascript"> function DispMsg(text1) { document.write("The text you submitted is: <br>" + text1.replace(/\n/g, "<br/>")); document.textform.reset(); } </SCRIPT> </head> <BODY> <FORM NAME=textform> <h2><b>Input Textarea Form</b></h2> <br> <TEXTAREA NAME="text1" rows="10" cols="40" TYPE="text">COPY/PASTE HERE</TEXTAREA> <INPUT NAME="submit" TYPE=Button VALUE="Submit" OnClick="DispMsg(form.text1.value)"> </FORM> </BODY> </html> HTML: I replaced the first line of your function "DispMsg" from... document.write("The text you submitted is: <br>" + text1); Code (markup): to... document.write("The text you submitted is: <br>" + text1.replace(/\n/g, "<br/>")); Code (markup): Hope that helps..