var log = document.getElementById("log");
$(function(){
$('textarea').keypress(function(e) {
if (e.keyCode == 13 && !e.shiftKey) {
log.innerHTML += "Company<br>";
e.preventDefault();
var frm = this.form; // don't submit the form yet
log.innerHTML += "<br>";
$.ajax({
url: $(frm).attr('action'), // remember to specify which attribute you want
data: $(frm).serialize(),
dataType: "json",
success: function() {
log.innerHTML += "Ajax complete (form should be submitted now)<br>";
// submit the form when the ajax request is complete
// frm.submit();
}
});
}
});
});
<form action="#">
<textarea name="comment"></textarea>
</form>
<div id="log"></div>
I am trying to set up the script to where I can display the results within the input. Is there a way to display the results whatever the user puts in the textarea below?
log.innerHTML += "Company<br>";
.innerHTML seems to be acting like a basic paragraph of text. All I need is to be able to display a list of links that are going to be put in the input to save them. Is there a way I can use .text() for the textarea?
Any help is appreciated, thank you!