a submit button is made to submit a form, which it will try to do, then reload the page. If it is outside the form it doesn't know what it is trying to submit, so will do nothing. Try:
Code:
<input type="button" value="submit" onclick="myFunction()">
which you can put anywhere
you should also note that values from text inputs are treated as strings even if they look like numbers. Your code would work better like this:
Code:
var beginVal = Number(fbForm.begin.value);
var endVal = Number(fbForm.end.value);