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
shouldgetelementbyid
this.total = this.total.tofixed(2);
work first time becausetotal
number. after becomes string ,tofixed
not valid method on string
Comments
Post a Comment