html - Uncaught TypeError: Cannot set property 'value' of null, JavaScript -


i keep on getting error when using code. src --> http://jsfiddle.net/myg2c/1/

js

    <input class="menu1" type="submit" value="total : 0.00" onclick="m.gettotal()" id="total" /> 

html

var m = {     total:0,     gettotal: function () {         this.total = this.total.tofixed(2);         document.getelementbyid("total").value = "total : " + this.total;     }, } m.total = 5; //clicking button should update text on button. 

two problems...

  • getelementbyid should getelementbyid
  • this.total = this.total.tofixed(2); work first time because total number. after becomes string , tofixed not valid method on string

updated fiddle


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -