Skip to content

Instantly share code, notes, and snippets.

@xxl007
Last active August 29, 2015 14:00
Show Gist options
  • Save xxl007/11124371 to your computer and use it in GitHub Desktop.
Save xxl007/11124371 to your computer and use it in GitHub Desktop.
Processing Individual Lines of a Textarea
// get textarea string and split on new lines
var txtBox = document.getElementById("inputbox");
var lines = txtBox.value.split("\n");
// generate HTML version of text
var resultString = "<p>";
for (var i = 0; i < lines.length ; i++) {
resultString += lines[i] + "<br />";
}
resultString += "</p>";
// print out last line to page
var blk = document.getElementById("result");
blk.innerHTML = resultString;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment