Your form and function both have the same name: calculate.
Perhaps that's confusing the browser. If you're using Firefox it
> var total = cost + inspayment;
The values entered in the text boxes might not be numbers. So
that line would cause an error. The function should anticipate