javascript - Print the result of a function in an alert box -


so have function, lets call calculate(). pulls data forms, , adds if items checked or filled in , adds together.

for sake of laziness looks this

<button onclick=calculate()>calculate total</button> <script type="text/javascript"> function calculate(); {     var number1 = 2;     var number2 = 3 var sumall = number1 + number2; //print result in "sum" paragraph, keep 2 decimals document.getelementbyid("sum").innerhtml = sumall.tofixed(2);     } </script> 

what want sounded easy, cannot figure out. want print result in alert box. newb?

if want simple alert box:

window.alert(sumall.tofixed(2)); 

or

alert(sumall.tofixed(2)); 

to print out in console debugging:

console.log(sumall.tofixed(2)); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -