I'm looking for a simple way to achieve this without a page refresh:
1.) User enters a PARAGRAPH of text into an editable field or <p>
2.) User clicks a button
3.) Text is duplicated/copied to a non-editable <p>
Any ideas? Thanks!
EDIT: Building on the selected answer below, here is one approach to maintaining the paragraph line breaks;
Javascript:
function copyAddress() {
var x = document.getElementById("INPUTPARA").value;
document.getElementById("DUPEPARA").innerHTML = x;
}
function addBreak(INPUTPARA) {
var textarea = INPUTPARA;
var matches = textarea.value.split(/\n|\s\n/);
textarea.value = matches.join("<br>\n") + "<br>";
}
function eraseText() {
document.getElementById("INPUTPARA").value = "";
}
HTML:
<textarea id="INPUTPARA"></textarea>
<button type="button" onclick="addBreak(this.previousElementSibling);copyAddress();eraseText()">Try it</button>
<p id="DUPEPARA"></p>