Once a page is fully loaded in the browser, any use of document.write
will *WIPE OUT* the ENTIRE page, even including the JS that did the document.write.
So you can *NEVER* use document.write to respond to any user-initiated event.
In general, if you find you are using document.write, you are probably making a mistake. (There are exceptions, but it's better to not look for them until you learn to avoid them.)
On a separate note, this is incorrect:
<input type="submit" id="submit" onSubmit="checkMox();">G0!</input>
(1) It's not legal HTML (because putting text between <input> and </input> is meaningless). [Didn't you notice that you created a button that said "Submit query" by doing that???]
(2) There is no such thing as an onsubmit
method for <input>. Only <form> has onsubmit
<form id="transMox" action="#output" method="post" onsubmit="return checkMox()">
That's good. But the problem is that your checkMox
function doesn't return true or false, so you can't predict what the return
there will do.
(Well, yes, as the code exists we can. Because checkMox will wipe out the entire HTML page so the return will never occur.)