I am relatively new to javascript and I created a function to multiply two numbers together, but document.write replaces the whole page with the answer. I know
If you add an empty element like <span id="fillme"></span> to the document you can use this with var fillme = document.getElementById("fillme"); and then later assign content to fillme with fillme.innerHTML = answer;
You already know how to use document.getElementById() to retrieve the values of inputs on your page. So do something similar to update an element that holds the answer:
<div id="answer"></div>
...and then:
document.getElementById("answer").innerHTML = answer;
Simle demo: http://jsfiddle.net/V5R5h/1/