I need to add data to an textarea, via javascript the only problem is if i will use multiple lines in value.="" the script will fail to work ! document.getElementById("textarea").value="domain1.com domain2.com domain3.com";
An example for it!!! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Textarea</title> </head> <body> <textarea id="textarea" name="textarea" cols="20" rows="10"></textarea> </body> <script> document.getElementById("textarea").value="domain1.com\n\rdomain2.com\n\rdomain3.com"; </script> </html> Code (markup):
document.getElementById("textarea").value = "domain1.com" + "\n" + "domain2.com" + "\n" + "domain3.com";
In javascript you can concatenate you string by using + operator. the charcter with space also use the same concept. so try to do concatenation.