Hello, I've get very elementary problem with javascript
I add onclick option to one of paragrahps, but it doesn't work properly,
It should display result of my new function, but it display result in a new, empty page.
(My function work properly, but connecting it with onclick and button is out of order)
Here's the code
function adding()
{
var piece1, piece2, result;
piece1=window.prompt('give first figure','');
piece2=window.prompt('give another figure','');
if (Number(piece1)) document.write('The first figure is okay!<br/>');
else {window.alert('Give proper figure!'); document.write('The first figure is wrong')};
if (Number(piece2)) document.write('The second figure is okay!<br/>');
else {window.alert('Give proper figure!'); document.write('The second figure is wrong')};
piece1=parseInt(piece1);
piece2=parseInt(piece2);
result=piece1 + piece2;
document.write(result);
return false;
};
</script>
<p onclick="adding()">Click to display result</p>
[ I guess that function could be smarter, but it's not the point - it's working but when I use onclick, it starts in a new card,on a new page)
Could You tell me what is wrong with my code? I will be grateful for all advices, however basic they may be :)