javascript - Accept integer or float type from user and add to array -


im trying add function accepts input user via value box. user types in int type or float value box , stored array. every time takes in new value, appends end of array. however, no matter do, keep getting error in console:

uncaught typeerror: cannot read property 'value' of null

what doing wrong? thanks.

charges = [];  function add() {  var charge = document.getelementbyid(inputcharge).value; charges.push(charge); document.getelementbyid('divresult').innerhtml = charges.join(""); }      <!doctype html> <html> <head><title></title> <script src="calculatetotal.js"></script> </head>  <body> charge<input type="number" id="inputcharge" value="">    <input type="submit" value="add" onclick="add()"><br> deduct<input type="number" id="deduction" value="">      <input type="submit" value="deduct" onclick="subtract()">   <div id="divcharge"> </div> <div id="divactivity"> activity:<br> </div>  <div id="divresult">     balance: </div>  <div id="divmessage"> </div>  </script> </body> </html>   </body>    </html> 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -