You cannot do anything
after a submit! That wipes out and reloads the page!
Cookies have been covered very many times in this forum. Try using the Search feature.
document.write statements must be run before the page finishes loading.
Any document.write statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page. So document.write is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.
To convert numbers to their written text form:-
Code:
<script type = "text/javascript">
var nums = ["One", "Two", "Three", "Four", "Five", "Six"];
var len = nums.length;
var x = Math.floor(len*Math.random());
alert (nums[x]); // a random number from One to Six
</script>