javascript - How would I append the result value? -


function getnote() {  var textfield = document.getelementbyid('textfield').value;  var result = document.getelementbyid('result');  result.innerhtml = textfield;   }   var submitbutton = document.getelementbyid('submitbutton');  submitbutton.addeventlistener('click',getnote);
<html lang="en">  <head>  <div id="wrapper">    <div class="topnav" id="mytopnav">    <a href="#home">notetaker</a>     </div>  <title>note taker</title>  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous"></head>  <body id="style">  <div id ="centerfield">  <h1> new note</h1>  <textarea  id="textfield"rows="8" cols="70%"  placeholder ="type here."></textarea>  <br>  <button type="button" id="submitbutton" class="btn btn-warning">submit information</button>  </div>  <div id ="leftfield" >   <h2> saved notes</h2>   <p id='result'></p></div>   <div id="container"></div>    </div>  </div>  </body>  </html>

i want every value keep being added field. when submit test , submit field should have both. right adds replace , im stumped.

if don't want ovveride , keep append, take old value , and add new value it.

result.innerhtml = result.innerhtml + " " + textfield;  

function getnote() {  var textfield = document.getelementbyid('textfield').value;  var result = document.getelementbyid('result');  result.innerhtml = result.innerhtml + " " + textfield;   }   var submitbutton = document.getelementbyid('submitbutton');  submitbutton.addeventlistener('click',getnote);
<html lang="en">  <head>  <div id="wrapper">    <div class="topnav" id="mytopnav">    <a href="#home">notetaker</a>     </div>  <title>note taker</title>  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-bvyiisifek1dgmjrakycuhahrg32omucww7on3rydg4va+pmstsz/k68vbdejh4u" crossorigin="anonymous"></head>  <body id="style">  <div id ="centerfield">  <h1> new note</h1>  <textarea  id="textfield"rows="8" cols="70%"  placeholder ="type here."></textarea>  <br>  <button type="button" id="submitbutton" class="btn btn-warning">submit information</button>  </div>  <div id ="leftfield" >   <h2> saved notes</h2>   <p id='result'></p></div>   <div id="container"></div>    </div>  </div>  </body>  </html>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -